mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Splits the logging in two loggers (console and file) so the logs can be formatted separately. A more complete console logging is required though. Right now it only should the message, but it would be nice to include also the parametters in a human-redable and friendly way. Fixing it using a single Logger will also be nice, but not worth spending too much on.
28 lines
705 B
Python
28 lines
705 B
Python
import logging
|
|
|
|
from pisa.utils.auth_proxy import AuthServiceProxy
|
|
import pisa.conf as conf
|
|
|
|
HOST = 'localhost'
|
|
PORT = 9814
|
|
|
|
# Create the file logger
|
|
f_logger = logging.getLogger('pisa_file_log')
|
|
f_logger.setLevel(logging.INFO)
|
|
|
|
fh = logging.FileHandler(conf.SERVER_LOG_FILE)
|
|
fh.setLevel(logging.INFO)
|
|
fh_formatter = logging.Formatter('%(message)s')
|
|
fh.setFormatter(fh_formatter)
|
|
f_logger.addHandler(fh)
|
|
|
|
# Create the console logger
|
|
c_logger = logging.getLogger('pisa_console_log')
|
|
c_logger.setLevel(logging.INFO)
|
|
|
|
ch = logging.StreamHandler()
|
|
ch.setLevel(logging.INFO)
|
|
ch_formatter = logging.Formatter('%(asctime)s %(message)s', '%Y-%m-%d %H:%M:%S')
|
|
ch.setFormatter(ch_formatter)
|
|
c_logger.addHandler(ch)
|