11"""
22Stackify Python API
33"""
4-
54__version__ = '0.0.1'
65
7-
8- API_URL = 'https://api.stackify.com'
9-
10- READ_TIMEOUT = 5000
11-
12- MAX_BATCH = 100
13-
14- QUEUE_SIZE = 1000
15-
166import logging
177import inspect
188import atexit
199
20- DEFAULT_LEVEL = logging .ERROR
21-
22- LOGGING_LEVELS = {
23- logging .CRITICAL : 'CRITICAL' ,
24- logging .ERROR : 'ERROR' ,
25- logging .WARNING : 'WARNING' ,
26- logging .INFO : 'INFO' ,
27- logging .DEBUG : 'DEBUG' ,
28- logging .NOTSET : 'NOTSET'
29- }
10+ from stackify .application import ApiConfiguration # noqa
11+ from stackify .constants import DEFAULT_LEVEL
12+ from stackify .handler import StackifyHandler
3013
3114
3215class NullHandler (logging .Handler ):
3316 def emit (self , record ):
3417 pass
3518
36- logging .getLogger (__name__ ).addHandler (NullHandler ())
37-
3819
39- from stackify .application import ApiConfiguration
40- from stackify .http import HTTPClient
41-
42- from stackify .handler import StackifyHandler
20+ logging .getLogger (__name__ ).addHandler (NullHandler ())
4321
4422
4523def getLogger (name = None , auto_shutdown = True , basic_config = True , ** kwargs ):
@@ -77,8 +55,6 @@ def getLogger(name=None, auto_shutdown=True, basic_config=True, **kwargs):
7755 if not [isinstance (x , StackifyHandler ) for x in logger .handlers ]:
7856 internal_logger = logging .getLogger (__name__ )
7957 internal_logger .debug ('Creating handler for logger %s' , name )
80- handler = StackifyHandler (** kwargs )
81- logger .addHandler (handler )
8258
8359 if auto_shutdown :
8460 internal_logger .debug ('Registering atexit callback' )
@@ -87,6 +63,9 @@ def getLogger(name=None, auto_shutdown=True, basic_config=True, **kwargs):
8763 if logger .getEffectiveLevel () == logging .NOTSET :
8864 logger .setLevel (DEFAULT_LEVEL )
8965
66+ handler = StackifyHandler (ensure_at_exit = not auto_shutdown , ** kwargs )
67+ logger .addHandler (handler )
68+
9069 handler .listener .start ()
9170
9271 return logger
0 commit comments