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.Path path
    inner path that you gave
    (package private) static java.lang.String prePath  
    (package private) java.util.Map<java.lang.String,​java.io.Writer> writers
    Map 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.log
    FieldLogger​(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
    void close()  
    private java.io.Writer createWriter​(java.io.File file)  
    void flush()  
    void log​(java.lang.String msg)
    Logs your message into /logger/innerPath/general.log
    void log​(java.lang.String fieldName, java.lang.String msg)
    Logs your message into specified field file: /logger/innerPath/fieldName.log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • prePath

      static final java.lang.String prePath
      See Also:
      Constant Field Values
    • path

      java.nio.file.Path path
      inner path that you gave
    • writers

      java.util.Map<java.lang.String,​java.io.Writer> writers
      Map 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 files
      fieldNames - - 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 files
      fieldName - - 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 name
      msg - - - log message
    • flush

      public void flush()
    • close

      public void close() throws java.lang.Exception
      Specified by:
      close in interface java.lang.AutoCloseable
      Throws:
      java.lang.Exception