LoggingΒΆ
pyqalx can write to local log files. The location of these is set in the configuration and the defaults
are qalx.log
and <bot_name>.<worker_index>.log
in the HOME folder.
The location and name of a log file can be configured and so can the level of logging. You can then use the pyqalx logger to log your own information or get debugging information.
from pyqalx import QalxSession
from pyqalx.config import UserConfig
my_config = {
"N_THINGS": 50,
"LOGGING_LEVEL": 'info', # will log everything at INFO and above
"LOG_FILE_PATH": r"C:\logs\my_log_file.log"
}
class MyLoggingConfig(UserConfig):
@property
def defaults(self):
config = super(MyLoggingConfig, self).defaults
config.update(my_config)
return config
qalx = QalxSession(config_class=MyLoggingConfig)
thing_item = qalx.item.add({"how_many":10*qalx.config['N_THINGS']})
qalx.log.info("added this many things: " + 10*qalx.config['N_THINGS']})
Inside your processing functions you can write to the logs with job.log
from pyqalx import Bot
my_bot = Bot("my bot")
@my_bot.process
def do_process(job):
job.log.info("LOG THIS!")
To assist with general debugging of pyqalx, setting the level to "DEBUG"
will output lots of
helpful (hopefully) information about requests to the REST API.