Working logging
This commit is contained in:
@@ -253,22 +253,13 @@ def application(environ, start_response):
|
||||
from repoze.who.config import make_middleware_with_config
|
||||
|
||||
APP_WITH_AUTH = make_middleware_with_config(application, {"here":"."},
|
||||
'./who.ini', log_file="app.log")
|
||||
'./who.ini', log_file="repoze_who.log")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
from wsgiref.simple_server import make_server
|
||||
import logging
|
||||
from saml2.config import LOG_FORMAT, LOG_HANDLER
|
||||
|
||||
handler = LOG_HANDLER["rotating"]("./idp.log")
|
||||
formatter = logging.Formatter(LOG_FORMAT)
|
||||
handler.setFormatter(formatter)
|
||||
root_logger.addHandler(handler)
|
||||
root_logger.info("Logging started")
|
||||
root_logger.setLevel(logging.INFO)
|
||||
|
||||
PORT = 8088
|
||||
|
||||
|
@@ -42,4 +42,12 @@ CONFIG={
|
||||
# the identifier returned to a SP
|
||||
#"xmlsec_binary": "/usr/local/bin/xmlsec1",
|
||||
"attribute_map_dir" : "./attributemaps",
|
||||
"logger": {
|
||||
"rotating": {
|
||||
"filename": "idp.log",
|
||||
"maxBytes": 100000,
|
||||
"backupCount": 5,
|
||||
},
|
||||
"loglevel": "debug",
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
import logging
|
||||
|
||||
import re
|
||||
from cgi import parse_qs
|
||||
@@ -157,8 +158,9 @@ def application(environ, start_response):
|
||||
|
||||
path = environ.get('PATH_INFO', '').lstrip('/')
|
||||
logger = environ.get('repoze.who.logger')
|
||||
if logger:
|
||||
logger.info("<application> PATH: %s" % path)
|
||||
logger.info("logger name: %s" % logger.name)
|
||||
logger.info(logging.Logger.manager.loggerDict)
|
||||
for regex, callback in urls:
|
||||
if user:
|
||||
match = re.search(regex, path)
|
||||
@@ -177,7 +179,7 @@ def application(environ, start_response):
|
||||
from repoze.who.config import make_middleware_with_config
|
||||
|
||||
app_with_auth = make_middleware_with_config(application, {"here":"."},
|
||||
'./who.ini', log_file="sp.log")
|
||||
'./who.ini', log_file="repoze_who.log")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
PORT = 8087
|
||||
|
@@ -41,5 +41,13 @@ CONFIG = {
|
||||
},
|
||||
],
|
||||
#"xmlsec_binary":"/usr/local/bin/xmlsec1",
|
||||
"name_form": NAME_FORMAT_URI
|
||||
"name_form": NAME_FORMAT_URI,
|
||||
"logger": {
|
||||
"rotating": {
|
||||
"filename": "sp.log",
|
||||
"maxBytes": 100000,
|
||||
"backupCount": 5,
|
||||
},
|
||||
"loglevel": "debug",
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ from saml2.profile import paos
|
||||
#from saml2.population import Population
|
||||
#from saml2.attribute_resolver import AttributeResolver
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger = logging.getLogger("repoze.who.sp")
|
||||
|
||||
PAOS_HEADER_INFO = 'ver="%s";"%s"' % (paos.NAMESPACE, ecp.SERVICE)
|
||||
|
||||
@@ -149,7 +149,7 @@ class SAML2Plugin(FormPluginBase):
|
||||
post_env = environ.copy()
|
||||
post_env['QUERY_STRING'] = ''
|
||||
|
||||
_ = get_body(environ, logger)
|
||||
_ = get_body(environ)
|
||||
|
||||
try:
|
||||
post = cgi.FieldStorage(
|
||||
@@ -511,7 +511,6 @@ def make_plugin(rememberer_name=None, # plugin for remember
|
||||
sid_store="",
|
||||
identity_cache="",
|
||||
discovery="",
|
||||
debug=0
|
||||
):
|
||||
|
||||
if saml_conf is "":
|
||||
|
@@ -63,7 +63,7 @@ except ImportError:
|
||||
except ImportError:
|
||||
from elementtree import ElementTree
|
||||
|
||||
root_logger = logging.getLogger("pySAML2")
|
||||
root_logger = logging.getLogger(__name__)
|
||||
root_logger.level = logging.NOTSET
|
||||
|
||||
NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion'
|
||||
|
@@ -111,6 +111,7 @@ class Saml2Client(object):
|
||||
raise Exception("Missing configuration")
|
||||
|
||||
self.metadata = self.config.metadata
|
||||
self.config.setup_logger()
|
||||
|
||||
# we copy the config.debug variable in an internal
|
||||
# field for convenience and because we may need to
|
||||
|
@@ -314,13 +314,15 @@ class Config(object):
|
||||
if root_logger.level != logging.NOTSET: # Someone got there before me
|
||||
return root_logger
|
||||
|
||||
if _logconf is None:
|
||||
return None
|
||||
try:
|
||||
_logconf = self._attr[""]["logger"]
|
||||
except KeyError:
|
||||
return root_logger
|
||||
|
||||
try:
|
||||
root_logger.setLevel(LOG_LEVEL[_logconf["loglevel"].lower()])
|
||||
except KeyError: # reasonable default
|
||||
root_logger.setLevel(logging.WARNING)
|
||||
root_logger.setLevel(logging.INFO)
|
||||
|
||||
root_logger.addHandler(self.log_handler())
|
||||
root_logger.info("Logging started")
|
||||
|
@@ -53,6 +53,6 @@ CONFIG={
|
||||
"maxBytes": 100000,
|
||||
"backupCount": 5,
|
||||
},
|
||||
"loglevel": "warning",
|
||||
"loglevel": "info",
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user