Class Writer
- java.lang.Object
-
- com.elvishew.xlog.printer.file.writer.Writer
-
- Direct Known Subclasses:
SimpleWriter
public abstract class Writer extends java.lang.ObjectA writer is used to write log into log file.Used in worker thread.
- Since:
- 1.11.0
-
-
Constructor Summary
Constructors Constructor Description Writer()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract voidappendLog(java.lang.String log)Append the log to the end of the opened log file, normally an extra line separator is needed.abstract booleanclose()Make sure the opened log file is closed, normally called before switching the log file.abstract java.io.FilegetOpenedFile()Get the opened log file.abstract java.lang.StringgetOpenedFileName()Get the name of opened log file.abstract booleanisOpened()Whether a log file is successfully opened in previousopen(File).abstract booleanopen(java.io.File file)Open a specific log file for future writing, if it doesn't exist yet, just create it.
-
-
-
Method Detail
-
open
public abstract boolean open(java.io.File file)
Open a specific log file for future writing, if it doesn't exist yet, just create it.- Parameters:
file- the specific log file, may not exist- Returns:
- true if the log file is successfully opened, false otherwise
-
isOpened
public abstract boolean isOpened()
Whether a log file is successfully opened in previousopen(File).- Returns:
- true if log file is opened, false otherwise
-
getOpenedFile
public abstract java.io.File getOpenedFile()
Get the opened log file.- Returns:
- the opened log file, or null if log file not opened
-
getOpenedFileName
public abstract java.lang.String getOpenedFileName()
Get the name of opened log file.- Returns:
- the name of opened log file, or null if log file not opened
-
appendLog
public abstract void appendLog(java.lang.String log)
Append the log to the end of the opened log file, normally an extra line separator is needed.- Parameters:
log- the log to append
-
close
public abstract boolean close()
Make sure the opened log file is closed, normally called before switching the log file.- Returns:
- true if the log file is successfully closed, false otherwise
-
-