6
6
7
7
from .context import SATOSABadContextError
8
8
from .exception import SATOSAError
9
- from .logging_util import satosa_logging
10
9
11
10
logger = logging .getLogger (__name__ )
12
11
@@ -66,9 +65,9 @@ def __init__(self, frontends, backends, micro_services):
66
65
else :
67
66
self .micro_services = {}
68
67
69
- logger .debug ("Loaded backends with endpoints: %s" % backends )
70
- logger .debug ("Loaded frontends with endpoints: %s" % frontends )
71
- logger .debug ("Loaded micro services with endpoints: %s" % micro_services )
68
+ logger .debug ("Loaded backends with endpoints: {}" . format ( backends ) )
69
+ logger .debug ("Loaded frontends with endpoints: {}" . format ( frontends ) )
70
+ logger .debug ("Loaded micro services with endpoints: {}" . format ( micro_services ) )
72
71
73
72
def backend_routing (self , context ):
74
73
"""
@@ -80,7 +79,9 @@ def backend_routing(self, context):
80
79
:param context: The request context
81
80
:return: backend
82
81
"""
83
- satosa_logging (logger , logging .DEBUG , "Routing to backend: %s " % context .target_backend , context .state )
82
+ msg = "Routing to backend: {backend}" .format (backend = context .target_backend )
83
+ logline = "[{id}] {message}" .format (id = context .state .get ("SESSION_ID" ), message = msg )
84
+ logger .debug (logline )
84
85
backend = self .backends [context .target_backend ]["instance" ]
85
86
context .state [STATE_KEY ] = context .target_frontend
86
87
return backend
@@ -97,7 +98,9 @@ def frontend_routing(self, context):
97
98
"""
98
99
99
100
target_frontend = context .state [STATE_KEY ]
100
- satosa_logging (logger , logging .DEBUG , "Routing to frontend: %s " % target_frontend , context .state )
101
+ msg = "Routing to frontend: {frontend}" .format (frontend = target_frontend )
102
+ logline = "[{id}] {message}" .format (id = context .state .get ("SESSION_ID" ), message = msg )
103
+ logger .debug (logline )
101
104
context .target_frontend = target_frontend
102
105
frontend = self .frontends [context .target_frontend ]["instance" ]
103
106
return frontend
@@ -109,7 +112,9 @@ def _find_registered_endpoint_for_module(self, module, context):
109
112
msg = "Found registered endpoint: module name:'{name}', endpoint: {endpoint}" .format (
110
113
name = module ["instance" ].name ,
111
114
endpoint = context .path )
112
- satosa_logging (logger , logging .DEBUG , msg , context .state )
115
+ logline = "[{id}] {message}" .format (
116
+ id = context .state .get ("SESSION_ID" ), message = msg )
117
+ logger .debug (logline )
113
118
return spec
114
119
115
120
return None
@@ -136,17 +141,24 @@ def endpoint_routing(self, context):
136
141
:return: registered endpoint and bound parameters
137
142
"""
138
143
if context .path is None :
139
- satosa_logging (logger , logging .DEBUG , "Context did not contain a path!" , context .state )
144
+ msg = "Context did not contain a path!"
145
+ logline = "[{id}] {message}" .format (
146
+ id = context .state .get ("SESSION_ID" ), message = msg )
147
+ logger .debug (logline )
140
148
raise SATOSABadContextError ("Context did not contain any path" )
141
149
142
- satosa_logging (logger , logging .DEBUG , "Routing path: %s" % context .path , context .state )
150
+ msg = "Routing path: {path}" .format (path = context .path )
151
+ logline = "[{id}] {message}" .format (id = context .state .get ("SESSION_ID" ), message = msg )
152
+ logger .debug (logline )
143
153
path_split = context .path .split ("/" )
144
154
backend = path_split [0 ]
145
155
146
156
if backend in self .backends :
147
157
context .target_backend = backend
148
158
else :
149
- satosa_logging (logger , logging .DEBUG , "Unknown backend %s" % backend , context .state )
159
+ msg = "Unknown backend {}" .format (backend )
160
+ logline = "[{id} {message}" .format (id = context .state .get ("SESSION_ID" ), message = msg )
161
+ logger .debug (logline )
150
162
151
163
try :
152
164
name , frontend_endpoint = self ._find_registered_endpoint (context , self .frontends )
0 commit comments