Logging
Glim has logging feature using python's standart logging
module. In glim, there exists 2 types(instances) of logging module. One of them is the "app" logger that is used inside web application flow. The other one is called "glim" logger which is used internally inside the framework. You can configure logging by the log
key of configuration;
# app/config/<env>.py
config = {
# ...
'log' : {
'app' : {
'level': 'info',
'format': '[%(levelname)s] - application : %(message)s',
'colored': True,
'file' : 'app/storage/logs/app.log'
},
'glim' : {
'level' : 'info',
'format' : '[%(levelname)s] : %(message)s',
'colored': True
'file' : 'app/storage/logs/glim.log'
},
},
# ...
}
This dictionary means that the logging will be done in "info" level and the format will be like
"[INFO] : msg". file
key stands for the file path of the log file. These keys have default values. If you don't provide a particular key, the default one will be configured. Here is a mapping of the default keys;
key | default value |
---|---|
level | debug |
format | "%(message)s" |
file | STD_OUT |
colored | True |
Usage
from glim import Log
# write a colorless string in debug level
Log.write('this is a log without color in debug level')
# log info level
Log.info('this is info')
# log warning level
Log.warning('this is warning')
# log debug level
Log.debug('this is debug')
# log error level
Log.error('this is error')
# log critical level
Log.critical('this is critical')
Updated less than a minute ago