15
15
See the License for the specific language governing permissions and
16
16
limitations under the License.
17
17
"""
18
- import yaml , json
19
- import logging
18
+ import yaml , json , os , sys
20
19
from .model .model import environment , credentials
21
20
21
+
22
+ import logging
23
+ logger = logging .getLogger (str (os .getpid ()) + '."' + __file__ + '"' )
24
+ # check if there are parents handlers. If not then add console output
25
+ if len (logging .getLogger (str (os .getpid ())).handlers ) == 0 :
26
+ logger .setLevel (logging .DEBUG )
27
+ fh = logging .StreamHandler (sys .stdout )
28
+ fh .setLevel (logging .DEBUG )
29
+ logger .addHandler (fh )
30
+ logger .debug ('Loaded ' + __file__ )
31
+
32
+
22
33
user_config_ids = ["sandbox-user" , "production-user" ]
23
34
24
35
class credentialutil (object ):
@@ -30,7 +41,7 @@ class credentialutil(object):
30
41
31
42
@classmethod
32
43
def load (cls , app_config_path ):
33
- logging .info ("Loading credential configuration file at: %s" , app_config_path )
44
+ logger .info ("Loading credential configuration file at: %s" , app_config_path )
34
45
with open (app_config_path , 'r' ) as f :
35
46
if app_config_path .endswith ('.yaml' ) or app_config_path .endswith ('.yml' ):
36
47
content = yaml .load (f )
@@ -43,7 +54,7 @@ def load(cls, app_config_path):
43
54
@classmethod
44
55
def _iterate (cls , content ):
45
56
for key in content :
46
- logging .debug ("Environment attempted: %s" , key )
57
+ logger .debug ("Environment attempted: %s" , key )
47
58
48
59
if key in [environment .PRODUCTION .config_id , environment .SANDBOX .config_id ]:
49
60
client_id = content [key ]['appid' ]
@@ -63,7 +74,7 @@ def get_credentials(cls, env_type):
63
74
"""
64
75
if len (cls ._credential_list ) == 0 :
65
76
msg = "No environment loaded from configuration file"
66
- logging .error (msg )
77
+ logger .error (msg )
67
78
raise CredentialNotLoadedError (msg )
68
79
return cls ._credential_list [env_type .config_id ]
69
80
0 commit comments