|
Lightweight 0.20260303.0
|
Represents a logger for SQL operations. More...
#include <SqlLogger.hpp>
Inherited by Lightweight::SqlLogger::Null.
Public Types | |
| enum class | SupportBindLogging : uint8_t { No , Yes } |
| Mandates the support for logging bind operations. More... | |
| using | MessageWriter = std::function< void(std::string)> |
| Type definition for a function that writes messages. | |
Public Member Functions | |
| LIGHTWEIGHT_API | SqlLogger (SqlLogger const &)=default |
| Default copy constructor. | |
| LIGHTWEIGHT_API | SqlLogger (SqlLogger &&)=default |
| Default move constructor. | |
| LIGHTWEIGHT_API SqlLogger & | operator= (SqlLogger const &)=default |
| Default copy assignment operator. | |
| LIGHTWEIGHT_API SqlLogger & | operator= (SqlLogger &&)=default |
| Default move assignment operator. | |
| LIGHTWEIGHT_API | SqlLogger (SupportBindLogging supportBindLogging, MessageWriter writer={}) |
| LIGHTWEIGHT_API void | SetLoggingSink (MessageWriter writer={}) |
| virtual void | OnWarning (std::string_view const &message)=0 |
| Invoked on a warning. | |
| virtual void | OnError (SqlError errorCode, std::source_location sourceLocation=std::source_location::current())=0 |
| Invoked on ODBC SQL error occurred. | |
| virtual void | OnError (SqlErrorInfo const &errorInfo, std::source_location sourceLocation=std::source_location::current())=0 |
| Invoked an ODBC SQL error occurred, with extended error information. | |
| virtual void | OnScopedTimerStart (std::string const &tag)=0 |
| Invoked when a scoped code region needs to be timed and logged. The region starts with this call. | |
| virtual void | OnScopedTimerStop (std::string const &tag)=0 |
| Invoked when a scoped code region needs to be timed and logged. The region ends with this call. | |
| virtual void | OnConnectionOpened (SqlConnection const &connection)=0 |
| Invoked when a connection is opened. | |
| virtual void | OnConnectionClosed (SqlConnection const &connection)=0 |
| Invoked when a connection is closed. | |
| virtual void | OnConnectionIdle (SqlConnection const &connection)=0 |
| Invoked when a connection is idle. | |
| virtual void | OnConnectionReuse (SqlConnection const &connection)=0 |
| Invoked when a connection is reused. | |
| virtual void | OnExecuteDirect (std::string_view const &query)=0 |
| Invoked when a direct query is executed. | |
| virtual void | OnPrepare (std::string_view const &query)=0 |
| Invoked when a query is prepared. | |
| template<typename T > | |
| void | OnBindInputParameter (std::string_view const &name, T &&value) |
| Invoked when an input parameter is bound. | |
| virtual void | OnBind (std::string_view const &name, std::string value)=0 |
| Invoked when an input parameter is bound, by name. | |
| virtual void | OnExecute (std::string_view const &query)=0 |
| Invoked when a prepared query is executed. | |
| virtual void | OnExecuteBatch ()=0 |
| Invoked when a batch of queries is executed. | |
| virtual void | OnFetchRow ()=0 |
| Invoked when a row is fetched. | |
| virtual void | OnFetchEnd ()=0 |
| Invoked when fetching is done. | |
Static Public Member Functions | |
| static LIGHTWEIGHT_API Null & | NullLogger () noexcept |
| Retrieves a null logger that does nothing. | |
| static LIGHTWEIGHT_API SqlLogger & | StandardLogger () |
| Retrieves a logger that logs to standard output. | |
| static LIGHTWEIGHT_API SqlLogger & | TraceLogger () |
| Retrieves a logger that logs to the trace logger. | |
| static LIGHTWEIGHT_API SqlLogger & | GetLogger () |
| Retrieves the currently configured logger. | |
| static LIGHTWEIGHT_API void | SetLogger (SqlLogger &logger) |
Protected Attributes | |
| MessageWriter | _messageWriter |
| The function used to write log messages. | |
Represents a logger for SQL operations.
Definition at line 21 of file SqlLogger.hpp.
| using Lightweight::SqlLogger::MessageWriter = std::function<void(std::string )> |
Type definition for a function that writes messages.
Definition at line 43 of file SqlLogger.hpp.
|
strong |
Mandates the support for logging bind operations.
Definition at line 25 of file SqlLogger.hpp.
|
explicit |
Constructs a new logger.
| supportBindLogging | Indicates if the logger should support bind logging. |
| writer | Optional message writer function for log output. |
| LIGHTWEIGHT_API void Lightweight::SqlLogger::SetLoggingSink | ( | MessageWriter | writer = {} | ) |
Sets the logging sink for the logger.
| writer | A function that takes a message string and writes it to the desired output. |
|
inline |
Invoked when an input parameter is bound.
Definition at line 92 of file SqlLogger.hpp.
References OnBind().
Referenced by Lightweight::SqlStatement::BindInputParameter(), and Lightweight::SqlStatement::Execute().
|
static |
Sets the current logger.
The ownership of the logger is not transferred and remains with the caller.
|
protected |
The function used to write log messages.
Definition at line 140 of file SqlLogger.hpp.