DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
Loading...
Searching...
No Matches
io.github.kdesp73.databridge.helpers.SQLogger Class Reference

Classes

enum  LogLevel
 
enum  LogType
 
enum  SQLOperation
 

Public Member Functions

void log (LogLevel lvl, String fmt, Object... args)
 
void log (LogLevel lvl, String msg)
 
void log (LogLevel lvl, String msg, Exception ex)
 
void log (LogLevel lvl, String msg, SQLOperation op, Object obj)
 
void logResultSet (ResultSet resultSet)
 

Static Public Member Functions

static String getCurrentTimestamp ()
 
static SQLogger getLogger ()
 
static SQLogger getLogger (LogLevel logLevel)
 
static SQLogger getLogger (LogLevel logLevel, LogType logType)
 
static void printSelf ()
 

Detailed Description

SQLogger is a logging utility class designed for logging SQL operations, including INSERT, UPDATE, DELETE, SELECT, and others. It supports various log levels (e.g., NONE, ERRO, WARN, INFO, ALL) and log types (e.g., FILE, STDERR, ALL). It can log to standard error, log files, or both. It also includes a method for formatting and printing SQL query result sets in a tabular format.

Version
0.0.2
Author
KDesp73

Member Function Documentation

◆ getLogger() [1/3]

static SQLogger io.github.kdesp73.databridge.helpers.SQLogger.getLogger ( LogLevel logLevel,
LogType logType )
static

Returns the singleton instance of SQLogger with specified log level and log type.

Parameters
logLevelthe log level.
logTypethe log type.
Returns
the SQLogger instance.

◆ getLogger() [2/3]

static SQLogger io.github.kdesp73.databridge.helpers.SQLogger.getLogger ( LogLevel logLevel)
static

Returns the singleton instance of SQLogger with specified log level, and default log type as ALL.

Parameters
logLevelthe log level.
Returns
the SQLogger instance.

◆ getLogger() [3/3]

static SQLogger io.github.kdesp73.databridge.helpers.SQLogger.getLogger ( )
static

Returns the singleton instance of SQLogger with default log level (ALL) and log type (ALL).

Returns
the SQLogger instance.

◆ printSelf()

static void io.github.kdesp73.databridge.helpers.SQLogger.printSelf ( )
static

Prints the current configuration of the SQLogger.

◆ getCurrentTimestamp()

static String io.github.kdesp73.databridge.helpers.SQLogger.getCurrentTimestamp ( )
static

Returns the current timestamp formatted as "yyyy-MM-dd HH:mm:ss".

Returns
the current timestamp.

◆ log() [1/4]

void io.github.kdesp73.databridge.helpers.SQLogger.log ( LogLevel lvl,
String fmt,
Object... args )

Logs a message with the specified log level and formatted arguments.

Parameters
lvlthe log level.
fmtthe format string.
argsthe arguments for the format string.

◆ log() [2/4]

void io.github.kdesp73.databridge.helpers.SQLogger.log ( LogLevel lvl,
String msg )

Logs a message with the specified log level.

Parameters
lvlthe log level.
msgthe message to log.

◆ log() [3/4]

void io.github.kdesp73.databridge.helpers.SQLogger.log ( LogLevel lvl,
String msg,
Exception ex )

Logs a message and an exception with the specified log level.

Parameters
lvlthe log level.
msgthe message to log.
exthe exception to log.

◆ log() [4/4]

void io.github.kdesp73.databridge.helpers.SQLogger.log ( LogLevel lvl,
String msg,
SQLOperation op,
Object obj )

Logs a SQL operation with the specified log level and operation details.

Parameters
lvlthe log level.
msgthe message to log.
opthe SQL operation being logged.
objthe object related to the operation.

◆ logResultSet()

void io.github.kdesp73.databridge.helpers.SQLogger.logResultSet ( ResultSet resultSet)

Logs the result set of a SQL query, printing the results in a formatted table.

Parameters
resultSetthe result set to log.

The documentation for this class was generated from the following file: