This is a very simple file logger for textual log outputs. The file name string provided in the constructor is not verified. The fileName may be changed any time by simply setting the public member fileName without the need of any other interaction other than acquiring the Lox
that this logger is attached to.
Public Fields | |
String | fileName |
boolean | hasIoError =false |
Public Fields inherited from PlainTextLogger | |
boolean | pruneESCSequences = true |
Public Fields inherited from TextLogger | |
AutoSizes | autoSizes = new AutoSizes() |
ObjectConverter | converter |
String | fmtMsgSuffix ="" |
String | fmtMultiLineMsgHeadline ="ALox: Multi line message follows: " |
String | fmtMultiLinePrefix = ">> " |
String | fmtMultiLineSuffix = null |
MetaInfo | metaInfo = new MetaInfo() |
String | multiLineDelimiter = null |
String | multiLineDelimiterRepl = "\\r" |
int | multiLineMsgMode = 2 |
Public Fields inherited from Logger | |
int | cntLogs |
Ticks | timeOfCreation = new Ticks() |
Ticks | timeOfLastLog = new Ticks() |
Public Fields inherited from ThreadLock | |
int | recursionWarningThreshold = 10 |
int | waitWarningTimeLimitInMillis = 1000 |
Public Methods | |
TextFileLogger (String fileName) | |
TextFileLogger (String fileName, String loggerName) | |
Public Methods inherited from TextLogger | |
int | addAcquirer (ThreadLock newAcquirer) |
void | clearReplacements () |
void | log (Domain domain, Verbosity verbosity, ArrayList< Object > logables, ScopeInfo scope) |
int | removeAcquirer (ThreadLock acquirer) |
void | resetAutoSizes () |
void | setReplacement (String searched, String replacement) |
Public Methods inherited from Logger | |
String | getName () |
String | getTypeName () |
String | toString () |
Public Methods inherited from SmartLock | |
SmartLock () | |
int | cntAcquirers () |
Public Methods inherited from ThreadLock | |
ThreadLock () | |
ThreadLock (LockMode lockMode) | |
ThreadLock (LockMode lockMode, Safeness safeness) | |
void | acquire () |
int | dbgCountAcquirements (Thread thread) |
LockMode | getMode () |
Safeness | getSafeness () |
void | release () |
void | setSafeness (Safeness safeness) |
boolean | willRelease () |
Protected Fields | |
BufferedWriter | bw |
boolean | currentlyInMultiLineOp |
FileWriter | fw |
Protected Fields inherited from TextLogger | |
AString | logBuf = new AString( 256 ) |
AString | msgBuf = new AString( 128 ) |
ArrayList< String > | replacements = new ArrayList<String>() |
int | stdStreamLockRegistrationCounter =0 |
boolean | usesStdStreams |
Protected Fields inherited from Logger | |
String | name |
String | typeName |
Protected Fields inherited from SmartLock | |
ArrayList< ThreadLock > | acquirers = new ArrayList<ThreadLock>() |
Protected Fields inherited from ThreadLock | |
int | cntAcquirements |
boolean | createOwnerStackTrace = false |
LockMode | lockMode |
Object | mutex |
Thread | owner |
Exception | ownerException |
Ticks | waitTime = new Ticks() |
Protected Methods | |
void | closeFile () |
boolean | logSubstring (AString buffer, int start, int length) |
boolean | notifyLogOp (Phase phase) |
void | notifyMultiLineOp (Phase phase) |
void | openFile () |
Protected Methods inherited from PlainTextLogger | |
PlainTextLogger (String name, String typeName, boolean usesStdStreams) | |
void | logText (Domain domain, Verbosity verbosity, AString msg, ScopeInfo scope, int lineNumber) |
Protected Methods inherited from TextLogger | |
TextLogger (String name, String typeName, boolean usesStdStreams) | |
Protected Methods inherited from Logger | |
Logger (String name, String typeName) | |
Additional Inherited Members | |
Package Access Methods inherited from ThreadLock | |
void | constructor (LockMode lockMode, Safeness safeness) |
TextFileLogger | ( | String | fileName, |
String | loggerName | ||
) |
Creates a TextFileLogger with the given name.
fileName | The filename (potentially including a path) of the output log file. |
loggerName | The name of the Logger. Defaults to "TEXTFILE". |
TextFileLogger | ( | String | fileName | ) |
Creates a TextFileLogger with the name "TEXTFILE".
fileName | The filename (potentially including a path) of the output log file. |
|
protected |
Closes the file.
|
protected |
Write the given region of the given AString to the destination buffer.
buffer | The string to write a portion of. |
start | The start of the portion in buffer to write out. |
length | The length of the portion in buffer to write out. |
true
if OK). Reimplemented from PlainTextLogger.
|
protected |
Start a new log line. Appends a new-line character sequence to previously logged lines.
phase | Indicates the beginning or end of a log operation. |
true
if OK). Reimplemented from PlainTextLogger.
|
protected |
Implementation of abstract interface signaling start and end of a multi line message. On start signal, the log file is opened, closed otherwise. Also stores the actual multi line message state in a field. This is for logText() to know whether file is to be opened/closed.
phase | Indicates the beginning or end of a multi-line operation. |
Reimplemented from TextLogger.
|
protected |
Opens the file.
|
protected |
Used to write into a log file.
|
protected |
Flag to prevent file open/close operations when multi-line text logging is performed.
String fileName |
The path and fileName to the log file.
|
protected |
Used to write into a log file.
boolean hasIoError =false |
Flag that indicates if there was an error opening he file