Size: 5004
Comment: Polished
|
← Revision 41 as of 2018-03-03 11:41:35 ⇥
Size: 129
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Managing Log Files = | = Logger: Managing Log Files = |
Line 3: | Line 3: |
{{{Logger}}} is part of the CategoryAplApl project. <<TableOfContents>> == Overview == This class offers methods useful to write and manage ordinary ANSI log files. In case any non-ANSI chars are part of a message these characters are replaced by question marks. In case you need Unicode log files you can achieve this by setting the `encoding` property to "UTF8". By default the class creates a log file with the name "yyyymmdd.log". When a new day puts in an appearance this file is closed and a new one is opened automatically. Instead of accepting the defaults you can also let the class create "yyyymm.log" files or even "yyyy.log". Note that the main method, `Log`, does not do any kind of fancy formatting. It just accepts vectors of any kind as well as text matrices; performance is considered to be paramount. However, the method `LogError` is different: in the event of errors performance considerations are less important. You won't have millions of errors to log and if you have something else to worry about. Note that by default the class makes intense use of error trapping to make sure that neither `Log` nor `LogError` will effect the hosting application. == Sample session == This code: {{{ myLogger←⎕NEW #.Logger(,⊂'') ⍝ Exercise the "Log" method" myLogger.Log'this is my first entry!' myLogger.Log'Even' 'more' 'entries' myLogger.Log⊃'A' 'text' 'matrix' myLogger.Log 1 2 3 myLogger.Log('String')(⍳6)('Another string') myLogger.Log(1 2)(2 3⍴⍳6) ⍝ causes an error (trapped!) {myLogger.Log'Log entry written in a thread'}&⍬ ⍝ Exercise the "LogError" method msg←'An error has occured' rc←0 myLogger.LogError rc msg ⍝ This has no effect: rc is 0 rc←2 myLogger.LogError rc msg more←'A fatal error has occured'(20 1009)((1 2)'FATAL'(2 3⍴⍳6)) myLogger.LogError rc msg more ⍝ "more" can be any array }}} Results in this log file: {{{ 2011-05-29 07:29:36 *** Log File opened 2011-05-29 07:29:36 this is my first entry! 2011-05-29 07:29:36 Even 2011-05-29 07:29:36 more 2011-05-29 07:29:36 entries 2011-05-29 07:29:36 A 2011-05-29 07:29:36 text 2011-05-29 07:29:36 matrix 2011-05-29 07:29:36 1 2 3 2011-05-29 07:29:36 String 2011-05-29 07:29:36 1 2 3 4 5 6 2011-05-29 07:29:36 Another string 2011-05-29 07:29:36 (2) Log entry written in a thread 2011-05-29 07:29:36 *** ERROR RC=2; An error has occured 2011-05-29 07:29:36 *** ERROR RC=2; An error has occured 2011-05-29 07:29:36 A fatal error has occured 2011-05-29 07:29:36 20 1009 2011-05-29 07:29:36 1 2 FATAL 1 2 3 2011-05-29 07:29:36 4 5 6 }}} Note that for the log entry written from its own thread the thread number is reported in the log file. == Constructors, fields, properties and methods == {{{ ]ADOC.List Logger *** Logger (Class) *** Constructors: make0 make1(y) make2(path_ encoding_) make3(path_ encoding_ filenameType_) make4(path_ encoding_ filenameType_ debug_) make5(path_ encoding_ filenameType_ debug_ timestamp_) make6(path_ encoding_ filenameType_ debug_ timestamp_ refToUtils_) Instance Properties: active autoReOpen debug encoding (ReadOnly) errorCounter (ReadOnly) errorPrefix extension fileFlag filenameDescriptor (ReadOnly) filenamePostfix filenamePrefix filenameType filename (ReadOnly) path (ReadOnly) printToSession refToUtils timestamp Instance Methods: Close r ← FullFilename {r} ← LogError y {r} ← Log Msg Shared Methods: r ← Copyright r ← CreatePropertySpace r ← History r ← Version }}} == Project Page == For bug reports, future enhancements and a full version history see [[Logger/ProjectPage]] == Version Information == ||Original author:||KaiJaeger|| ||Responsible:||KaiJaeger|| ||Email:||kai@aplteam.com|| ||License:||Free software|| ||Current state:||1.5.0|| == Download == You have two options: you can either download the script for usage: [[http://aplwiki.com/Logger?action=AttachFile&do=get&target=Logger.ZIP | Download Logger script right now]] or get the whole thing from the AplWikiRepository, including the development workspace and the script and maybe more for any development or for running the test cases: {{{ svn list svn://aplteam.com/os/dyalog/Logger/tags }}} If you plan to contribute please note that all stuff published as part of the APLAPL project must follow certain [[AplAplStandards|APLAPL-specific standards]]. ---- CategoryAplApl |
The project has been relocated to [[https://github.com/aplteam/Markdown2Help]] on 2018-03-03. |
Logger: Managing Log Files
The project has been relocated to https://github.com/aplteam/Markdown2Help on 2018-03-03.