Basic library for logs, this logs are displayed with ANSI colours in linux terminals (windows yet to come). Features:
- Logs can be stored in database if configuration is provided.
- Logs can be ignored with the configuration (this is usefull for diferent stages configuration)
- Library can be extended using the interface provided
To use this library you have to initialize it with a configuration:
example without database configuration
config := models.Configuration{DisplayLogs: true, SaveLogs: false,
LogLevels: models.DisplayConfiguration{
DisplayDebug: true,
DisplayWarnings: true,
DisplayError: true,
DisplayInfo: true,
},
}
logger := logger.New(config)
After initialize the libreary with the configuration we can use the diferent functions provided
logger.DEBUG("I'm debug");
logger.ERROR("I', error");
logger.INFO("I'm info");
logger.WARNING("I'm waring");
You can find the examples in ./examples
Format: Date - type - message
Log Types:
- INFO : display an info message blue colour
INFO(message string)
- ERROR : display an error message red colour
ERROR(message string)
- WARNING : display a warning message yellow colour
WARNING(message string)
- DEBUG : display a debug message purple colour
DEBUG(message string)
Logs can be saved in a database, repository implementation have to be provided in the configuration with the Repository interface implemented (see withDataBase in ./example)