1414DEFAULT_FLUSH_INTERVAL = 1
1515DEFAULT_RAISE_EXCEPTIONS = False
1616DEFAULT_DROP_EXTRA_EVENTS = True
17+ DEFAULT_INCLUDE_EXTRA_ATTRIBUTES = True
1718
1819
1920class LogtailHandler (logging .Handler ):
@@ -24,6 +25,7 @@ def __init__(self,
2425 flush_interval = DEFAULT_FLUSH_INTERVAL ,
2526 raise_exceptions = DEFAULT_RAISE_EXCEPTIONS ,
2627 drop_extra_events = DEFAULT_DROP_EXTRA_EVENTS ,
28+ include_extra_attributes = DEFAULT_INCLUDE_EXTRA_ATTRIBUTES ,
2729 context = DEFAULT_CONTEXT ,
2830 level = logging .NOTSET ):
2931 super (LogtailHandler , self ).__init__ (level = level )
@@ -33,6 +35,7 @@ def __init__(self,
3335 self .pipe = multiprocessing .JoinableQueue (maxsize = buffer_capacity )
3436 self .uploader = Uploader (self .source_token , self .host )
3537 self .drop_extra_events = drop_extra_events
38+ self .include_extra_attributes = include_extra_attributes
3639 self .buffer_capacity = buffer_capacity
3740 self .flush_interval = flush_interval
3841 self .raise_exceptions = raise_exceptions
@@ -54,7 +57,7 @@ def emit(self, record):
5457 if self ._is_main_process () and not self .flush_thread .is_alive ():
5558 self .flush_thread .start ()
5659 message = self .format (record )
57- frame = create_frame (record , message , self .context )
60+ frame = create_frame (record , message , self .context , include_extra_attributes = self . include_extra_attributes )
5861 try :
5962 self .pipe .put (frame , block = (not self .drop_extra_events ))
6063 except queue .Full :
0 commit comments