Class Logging
java.lang.Object
org.noise_planet.noisemodelling.webserver.utilities.Logging
Utility functions related to logging features
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendSuppressed(StringBuilder sb, Throwable sup, IdentityHashMap<Throwable, Boolean> seen, String prefix) static voidstatic voidconfigureLoggerFromWorkingDirectory(String workingDirectory, String loggingFileName, boolean verbose) static org.apache.log4j.RollingFileAppendercreateRollingFileAppender(String workingDirectory, String loggingFileName) static StringformatSqlQueryResult(groovy.sql.Sql sql, Object query) Executes a SQL query and return the result set as an ASCII table.static StringformatSqlQueryResult(groovy.sql.Sql sql, Object query, int maxColWidth) Executes a SQL query and return the result set as an ASCII table.static StringformatThrowableAsHtml(Throwable throwable) Build an HTML-friendly stack trace string similar to what SLF4J would print, including the exception type, message, stack frames, causes, and suppressed exceptions.static StringgetAllLines(String jobId, File loggingFile, int numberOfLines) Return lines from the most recent to the old onesstatic StringgetLastLines(File logFile, int maximumLinesToFetch, String jobId, AtomicInteger fetchedLines) Equivalent to "tail -n x file" linux command.static void
-
Field Details
-
DEFAULT_LOG_FORMAT
- See Also:
-
LOG_PATTERN
-
LINE_SEPARATOR
-
-
Constructor Details
-
Logging
public Logging()
-
-
Method Details
-
initConsoleLogging
public static void initConsoleLogging() -
configureLoggerFromWorkingDirectory
-
clearAppenders
public static void clearAppenders() -
createRollingFileAppender
-
formatThrowableAsHtml
Build an HTML-friendly stack trace string similar to what SLF4J would print, including the exception type, message, stack frames, causes, and suppressed exceptions. -
appendSuppressed
public static void appendSuppressed(StringBuilder sb, Throwable sup, IdentityHashMap<Throwable, Boolean> seen, String prefix) -
getAllLines
public static String getAllLines(String jobId, File loggingFile, int numberOfLines) throws IOException Return lines from the most recent to the old ones- Parameters:
jobId-numberOfLines-- Returns:
- Throws:
IOException
-
getLastLines
public static String getLastLines(File logFile, int maximumLinesToFetch, String jobId, AtomicInteger fetchedLines) throws IOException Equivalent to "tail -n x file" linux command. Retrieve the n last lines from a file but from the most recent to the oldest one.- Parameters:
logFile-maximumLinesToFetch-- Returns:
- Throws:
IOException
-
formatSqlQueryResult
Executes a SQL query and return the result set as an ASCII table.- Parameters:
sql- An instance of groovy.sql.Sqlquery- A String or GString (allows for parameter injection)
-
formatSqlQueryResult
Executes a SQL query and return the result set as an ASCII table.- Parameters:
sql- An instance of groovy.sql.Sqlquery- A String or GString (allows for parameter injection)maxColWidth- Maximum width of a column before truncation
-