Size: 1264
Comment:
|
Size: 5006
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
[[TableOfContents]] | {{{Logger}}} is part of the CategoryAplTree project. <<TableOfContents>> |
Line 7: | Line 9: |
'''Currently under construction''' | 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". |
Line 9: | Line 11: |
This class offers methods useful to write and manage ordinary ANSI log files. | 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. |
Line 11: | Line 13: |
== Constructors, Methods and Properties == | 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: |
Line 14: | Line 24: |
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) *** |
|
Line 15: | Line 76: |
make1(active_) make2(active_ path_) make3(active_ path_ type_) make4(active_ path_ type_ debug_) make5(active_ path_ type_ debug_ refToWinFile_) make6(active_ path_ type_ debug_ refToWinFile_ refToUtils_) make7(active_ path_ type_ debug_ refToWinFile_ refToUtils_ timestamp_) |
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_) |
Line 26: | Line 87: |
encoding (ReadOnly) | |
Line 29: | Line 91: |
filename (ReadOnly) | fileFlag |
Line 34: | Line 96: |
filename (ReadOnly) | |
Line 37: | Line 100: |
refToWinFile | |
Line 40: | Line 102: |
Log LogError |
Close r ← FullFilename {r} ← LogError y {r} ← Log Msg |
Line 43: | Line 107: |
Version | r ← Copyright r ← CreatePropertySpace r ← History r ← Version |
Line 45: | Line 113: |
== Project Page == | |
Line 46: | Line 115: |
== History == For a full version history: [:WinReg/History: History] |
For bug reports, future enhancements and a full version history see [[Logger/ProjectPage]] |
Line 56: | Line 122: |
||Current state:||1.0|| | ||License:||Free software|| ||Current state:||1.6.0|| |
Line 59: | Line 126: |
Goto the [:LoggerDownloadPage:LoggerDownloadPage] | 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]]. |
Line 62: | Line 140: |
CategoryOpenSourceApl CategoryAplAplDyalog | CategoryAplTree |
Managing Log Files
Logger is part of the CategoryAplTree project.
Contents
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: |
|
Responsible: |
|
Email: |
|
License: |
Free software |
Current state: |
1.6.0 |
Download
You have two options: you can either download the script for usage:
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 APLAPL-specific standards.