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