Package com.github.rhys_h_walker
Class FileManagement
java.lang.Object
com.github.rhys_h_walker.FileManagement
A static class which implements most of the IO features required by OnRailsLogger
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
locateFile
(LocalDateTime ts, File applicationDirectory) Based on a timestamp either locate or create a file for loggingreadLogFile
(File logFile) Read in a log file and return it split by linestatic void
writeToLogFile
(String timestamp, LoggingType logType, String message, PrintWriter pw) Write a log message to a given file.
-
Method Details
-
locateFile
Based on a timestamp either locate or create a file for logging- Parameters:
ts
- The timestamp String to use, format of (YYYY-MM-DD-HH:MM:SS)applicationDirectory
- A File object which points to the current applications logging directory- Returns:
- The File object, null on any errors
-
writeToLogFile
public static void writeToLogFile(String timestamp, LoggingType logType, String message, PrintWriter pw) Write a log message to a given file.- Parameters:
timestamp
- The timestamp String to use, format of (YYYY-MM-DD-HH:MM:SS)logType
- The type of log that is being outputmessage
- The logging message that is being outputpw
- Printwriter which is pointed to the file to write, this is cycled in log factory
-
readLogFile
Read in a log file and return it split by line- Parameters:
logFile
- The File to be read from- Returns:
- An ArrayList of Strings (Each string is a line), null if error
-