1212from config import ServerConfig
1313from misc import force_remove , get_mtime
1414
15+ logger = logging .getLogger (__name__ )
1516
1617def send (data ):
1718 data_str = json .dumps (data )
18- logging .debug ("Res <-- %s" , data_str )
19+ logger .debug ("Res <-- %s" , data_str )
1920 try :
2021 sys .stdout .write (f"Content-Length: { len (data_str )} \r \n \r \n { data_str } " )
2122 sys .stdout .flush ()
@@ -78,7 +79,7 @@ def reinit_compile_info(self):
7879 self ._compile_file = self .get_compile_file (self .config )
7980 if os .path .exists (self ._compile_file ):
8081 self .compile_file = self ._compile_file
81- logging .info (f"use flags from { self ._compile_file } " )
82+ logger .info (f"use flags from { self ._compile_file } " )
8283 else :
8384 self .compile_file = None
8485
@@ -127,7 +128,7 @@ def notify_option_changed(self, uri):
127128 send (notification )
128129 return True
129130 except ValueError as e : # may have other type change register, like target
130- logging .debug (e )
131+ logger .debug (e )
131132
132133 def shutdown (self ):
133134 self .observed_thread = None # release to end in subthread
@@ -136,7 +137,7 @@ def shutdown(self):
136137
137138 def start_observe_changes (self ):
138139 if self .observed_thread :
139- logging .warn ("already observing!!" )
140+ logger .warn ("already observing!!" )
140141 return
141142
142143 def start ():
@@ -149,7 +150,7 @@ def start():
149150 self .tick ()
150151 time .sleep (1 )
151152 except Exception as e :
152- logging .exception (f"observe thread exit by exception: { e } " )
153+ logger .exception (f"observe thread exit by exception: { e } " )
153154
154155 self .locking_compile_file = False
155156
@@ -199,7 +200,7 @@ def check_locking_compile_file(self):
199200 elif time .time () - mtime < 180 :
200201 return True # still wait
201202 else :
202- logging .warn ("updating compile lock timeout! reset it" )
203+ logger .warn ("updating compile lock timeout! reset it" )
203204 force_remove (self .compile_lock_path )
204205
205206 self .locking_compile_file = False
@@ -287,7 +288,7 @@ def build_initialize(message):
287288 state = State (root_path , cache_path )
288289 global shared_state
289290 if shared_state :
290- logging .warn ("already initialized!!" )
291+ logger .warn ("already initialized!!" )
291292 else :
292293 shared_state = state
293294
@@ -423,7 +424,7 @@ def build_exit(message):
423424
424425
425426def serve ():
426- logging .info ("Xcode Build Server Startup" )
427+ logger .info ("Xcode Build Server Startup" )
427428 while True :
428429 line = sys .stdin .readline ()
429430 if len (line ) == 0 :
@@ -434,7 +435,7 @@ def serve():
434435 sys .stdin .readline ()
435436 raw = sys .stdin .read (length )
436437 message = json .loads (raw )
437- logging .debug ("Req --> " + raw )
438+ logger .debug ("Req --> " + raw )
438439
439440 with lock :
440441 response = None
0 commit comments