Logging
An example of logging Requests
Query logging in my ORM system allows tracking all SQL operations, providing transparency and simplifying the process of diagnostics and debugging. Enabling logging ensures that all queries passing through the system are recorded, as well as any errors occurring during query execution.
Activating Logging
To enable logging in my ORM system, configure the DatabaseManager
with the logging: true
parameter. This will allow recording all queries and errors to a log file:
Example of Using Logging
In my ORM system, two main methods are available for logging:
log(message: string, sql?: string, params?: string): void
: Used for recording informational messages and successfully executed queries.error(message: string, sql?: string, params?: string): void
: Used for recording error messages and failed queries.
Example:
Log Structure
All logs are stored in the app.log
file and include information about the time, event type (INFO or ERROR), SQL query, and passed parameters. Example content of the log file:
Query logging in my ORM system provides an effective way to track and diagnose SQL operations by storing information about queries and errors in a dedicated file. This allows for quick identification and resolution of potential issues, improving system stability and transparency. Logging can be easily activated by configuring the logging
parameter in the DatabaseManager
configuration.
Last updated