Skip to content

Commit

Permalink
Merge b2c559d into bde125b
Browse files Browse the repository at this point in the history
  • Loading branch information
rwols committed Aug 26, 2019
2 parents bde125b + b2c559d commit 09ed348
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugin/core/logging.py
@@ -1,7 +1,9 @@
import traceback
from threading import Lock

log_debug = False
log_exceptions = True
mutex = Lock()


def set_debug_logging(logging_enabled: bool) -> None:
Expand All @@ -17,18 +19,21 @@ def set_exception_logging(logging_enabled: bool) -> None:
def debug(*args):
"""Print args to the console if the "debug" setting is True."""
if log_debug:
printf(*args)
with mutex:
printf(*args)


def exception_log(message: str, ex) -> None:
if log_exceptions:
print(message)
ex_traceback = ex.__traceback__
print(''.join(traceback.format_exception(ex.__class__, ex, ex_traceback)))
with mutex:
print(message)
ex_traceback = ex.__traceback__
print(''.join(traceback.format_exception(ex.__class__, ex, ex_traceback)))


def server_log(server_name, *args) -> None:
printf(*args, prefix=server_name)
with mutex:
printf(*args, prefix=server_name)


def printf(*args, prefix='LSP'):
Expand Down

0 comments on commit 09ed348

Please sign in to comment.