Size: 2640
Comment: History replaced by ProjectPage
|
Size: 5005
Comment: New version
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
{{{Logger}}} is part of the CategoryAplApl project. | {{{Logger}}} is part of the CategoryAplTree project. |
Line 9: | Line 9: |
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. | 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 11: | Line 11: |
By default, the class creates a log file as an ordinary ANSI file with the name "yyyymmdd.txt". When a new day puts in an appearance, this file is closed and a new one is opened automatically. | 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 13: | Line 13: |
Instead of accepting the defaults you can also let the class create "yyyymm.txt" files or even "yyyy.txt". | Instead of accepting the defaults you can also let the class create "yyyymm.log" files or even "yyyy.log". |
Line 15: | Line 15: |
The main function, '''Log''', creates entries as such: | 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 18: | Line 24: |
20080721115636 *** Log File opened 20080721115636 (1) 127.0.0.1:2152 has connected |
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 |
Line 22: | Line 43: |
The number between the brackets (1) is the thread number. The number is not reported for thread number 0. Note that the class makes intense use of error trapping to make sure that a problem in the Logger class will not effect the hosting application. == Constructors, Methods and Properties == |
Results in this log file: |
Line 29: | Line 46: |
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 30: | 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 41: | Line 87: |
encoding (ReadOnly) | |
Line 44: | Line 91: |
filename (ReadOnly) | fileFlag |
Line 49: | Line 96: |
filename (ReadOnly) | |
Line 52: | Line 100: |
refToWinFile | |
Line 55: | Line 102: |
Log LogError |
Close r ← FullFilename {r} ← LogError y {r} ← Log Msg |
Line 58: | Line 107: |
Version | r ← Copyright r ← CreatePropertySpace r ← History r ← Version |
Line 60: | Line 113: |
Line 71: | Line 122: |
||Current state:||1.4.0|| | ||License:||Free software|| ||Current state:||1.6.0|| |
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.