Skip to content

Commit 3af213f

Browse files
committed
chore: server add a detail logger
1 parent cef85c4 commit 3af213f

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

compile_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def InferFlagsForSwift(filename, store):
231231
"""try infer flags by convention and workspace files"""
232232
global firstCompileFile
233233
project_root, flagFile, compileFile = findSwiftModuleRoot(filename)
234-
logging.debug(f"root: {project_root}, {compileFile}")
234+
logging.debug(f"infer root: {project_root}, {compileFile}")
235235
if firstCompileFile is None:
236236
firstCompileFile = compileFile
237237
final_flags = GetFlagsInCompile(filename, compileFile, store)

server.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
from config import ServerConfig
1313
from misc import force_remove, get_mtime
1414

15+
logger = logging.getLogger(__name__)
1516

1617
def 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

425426
def 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

xclog_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def echo(s: str):
1414
if hooks_echo_to_log:
15-
logging.debug(s)
15+
logging.getLogger("parser").debug(s)
1616
else:
1717
print(s, file=sys.stderr)
1818

xcode-build-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def setup_root_logger():
5252
logging.basicConfig(stream=sys.stderr, level=level)
5353

5454
if xbs_debug:
55-
logging.info(f"# xcode builde server with python {sys.version}]")
55+
logging.info(f"# xcode build server with python {sys.version}]")
5656

5757

5858
def main():

0 commit comments

Comments
 (0)