Skip to content

Commit 28eacc5

Browse files
authored
add pipe sleection for logs (#763)
1 parent ba0468e commit 28eacc5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/opal-common/opal_common/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class OpalCommonConfig(Confi):
4040
LOG_SERIALIZE = confi.bool(
4141
"LOG_SERIALIZE", False, description="Serialize log messages"
4242
)
43+
LOG_PIPE_TO_STDERR = confi.bool(
44+
"LOG_PIPE_TO_STDERR",
45+
True,
46+
description="Should we send logs to stderr? otherwise to stdout",
47+
)
4348
LOG_SHOW_CODE_LINE = confi.bool(
4449
"LOG_SHOW_CODE_LINE", True, description="Show code line in log messages"
4550
)
@@ -68,6 +73,7 @@ class OpalCommonConfig(Confi):
6873
LOG_TO_FILE = confi.bool(
6974
"LOG_TO_FILE", False, description="Should we log to a file"
7075
)
76+
7177
LOG_FILE_PATH = confi.str(
7278
"LOG_FILE_PATH",
7379
f"opal_{PROCESS_NAME}{{time}}.log",

packages/opal-common/opal_common/logger.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ def configure_logs():
2929
# Clean slate
3030
logger.remove()
3131
# Logger configuration
32+
pipe = sys.stderr if opal_common_config.LOG_PIPE_TO_STDERR else sys.stdout
3233
logger.add(
33-
sys.stderr,
34+
pipe,
3435
filter=filter.filter,
3536
format=formatter.format,
3637
level=opal_common_config.LOG_LEVEL,

0 commit comments

Comments
 (0)