diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-09-29 14:36:41 +0300 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-09-29 14:41:48 +0300 |
commit | b4fd75475638c3318dfd00ea6cf0c2a56504a444 (patch) | |
tree | d0676b6b04a1d36b3ba546e8c76e771a22e96603 /src/saml2/config.py | |
parent | d62a10c473f64e389d2d26958c83c83daafe38fd (diff) | |
download | pysaml2-b4fd75475638c3318dfd00ea6cf0c2a56504a444.tar.gz |
Support logging configuration through the python logger
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src/saml2/config.py')
-rw-r--r-- | src/saml2/config.py | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/saml2/config.py b/src/saml2/config.py index dbf57aa3..eb00c7cf 100644 --- a/src/saml2/config.py +++ b/src/saml2/config.py @@ -7,6 +7,7 @@ import logging.handlers import os import re import sys +from logging.config import dictConfig as configure_logging_by_dict import six @@ -30,6 +31,7 @@ __author__ = 'rolandh' COMMON_ARGS = [ + "logging", "debug", "entityid", "xmlsec_binary", @@ -141,24 +143,6 @@ SPEC = { "aq": COMMON_ARGS + COMPLEX_ARGS + AQ_ARGS, } -# --------------- Logging stuff --------------- - -LOG_LEVEL = { - 'debug': logging.DEBUG, - 'info': logging.INFO, - 'warning': logging.WARNING, - 'error': logging.ERROR, - 'critical': logging.CRITICAL} - -LOG_HANDLER = { - "rotating": logging.handlers.RotatingFileHandler, - "syslog": logging.handlers.SysLogHandler, - "timerotate": logging.handlers.TimedRotatingFileHandler, - "memory": logging.handlers.MemoryHandler, -} - -LOG_FORMAT = "%(asctime)s %(name)s:%(levelname)s %(message)s" - _RPA = [BINDING_HTTP_REDIRECT, BINDING_HTTP_POST, BINDING_HTTP_ARTIFACT] _PRA = [BINDING_HTTP_POST, BINDING_HTTP_REDIRECT, BINDING_HTTP_ARTIFACT] _SRPA = [BINDING_SOAP, BINDING_HTTP_REDIRECT, BINDING_HTTP_POST, @@ -190,6 +174,7 @@ class Config(object): def_context = "" def __init__(self, homedir="."): + self.logging = None self._homedir = homedir self.entityid = None self.xmlsec_binary = None @@ -362,6 +347,9 @@ class Config(object): except TypeError: # Something that can't be a string setattr(self, arg, cnf[arg]) + if self.logging is not None: + configure_logging_by_dict(self.logging) + if not self.delete_tmpfiles: logger.warning( "delete_tmpfiles is set to False; " |