Package logger
Class FieldLogger
java.lang.Object
logger.FieldLogger
- All Implemented Interfaces:
java.lang.AutoCloseable
public class FieldLogger
extends java.lang.Object
implements java.lang.AutoCloseable
MathLogger for organized logging of fields that you gave.
Root directory: ./logger/
All your log files will be in: /log/yourPath/fieldName.
You can name fields that you want to log.
Logs to ./logger/innerPath/fieldName.log
Field name "general" is reserved by logger.
general.log - for general logging information.
Each log separates by "\n".
Rewrites all data that were in files.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.nio.file.Pathpathinner path that you gave(package private) static java.lang.StringprePath(package private) java.util.Map<java.lang.String,java.io.Writer>writersMap for fields: contains pairs: fieldName -> writer to field's file -
Constructor Summary
Constructors Constructor Description FieldLogger(java.lang.String innerPath)Logs only into /logger/innerPath/general.logFieldLogger(java.lang.String innerPath, java.lang.String fieldName)Creates new Logger that logs to /logger/innerPath/fieldName.log Have only one field.FieldLogger(java.lang.String innerPath, java.util.List<java.lang.String> fieldNames)Creates new Logger that logs to /logger/innerPath/fieldName.log -
Method Summary
Modifier and Type Method Description voidclose()private java.io.WritercreateWriter(java.io.File file)voidflush()voidlog(java.lang.String msg)Logs your message into /logger/innerPath/general.logvoidlog(java.lang.String fieldName, java.lang.String msg)Logs your message into specified field file: /logger/innerPath/fieldName.log
-
Field Details
-
prePath
static final java.lang.String prePath- See Also:
- Constant Field Values
-
path
java.nio.file.Path pathinner path that you gave -
writers
java.util.Map<java.lang.String,java.io.Writer> writersMap for fields: contains pairs: fieldName -> writer to field's file
-
-
Constructor Details
-
FieldLogger
public FieldLogger(java.lang.String innerPath, java.util.List<java.lang.String> fieldNames)Creates new Logger that logs to /logger/innerPath/fieldName.log- Parameters:
innerPath- - inner path for storing field's filesfieldNames- - list of field names
-
FieldLogger
public FieldLogger(java.lang.String innerPath, java.lang.String fieldName)Creates new Logger that logs to /logger/innerPath/fieldName.log Have only one field.- Parameters:
innerPath- - inner path for storing field's filesfieldName- - fieldName
-
FieldLogger
public FieldLogger(java.lang.String innerPath)Logs only into /logger/innerPath/general.log- Parameters:
innerPath- - inner path for storing field's files
-
-
Method Details
-
createWriter
private java.io.Writer createWriter(java.io.File file) -
log
public void log(java.lang.String msg)Logs your message into /logger/innerPath/general.log- Parameters:
msg- - log message
-
log
public void log(java.lang.String fieldName, java.lang.String msg)Logs your message into specified field file: /logger/innerPath/fieldName.log- Parameters:
fieldName- - field namemsg- - - log message
-
flush
public void flush() -
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-