Skip to content

Commit

Permalink
Fix: Log level could not be configured from settings
Browse files Browse the repository at this point in the history
Solution: Add a `LOG_LEVEL` setting defaulting to "WARNING".

Replace PR #581

#581
  • Loading branch information
olethanh committed Nov 5, 2024
1 parent 451f246 commit c2bc731
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/aleph/vm/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Settings(BaseSettings):
# System logs make boot ~2x slower
PRINT_SYSTEM_LOGS = False
IGNORE_TRACEBACK_FROM_DIAGNOSTICS = True
LOG_LEVEL = "WARNING"
DEBUG_ASYNCIO = False

# Networking does not work inside Docker/Podman
Expand Down
9 changes: 7 additions & 2 deletions src/aleph/vm/orchestrator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def parse_args(args):
help="set loglevel to INFO",
action="store_const",
const=logging.INFO,
default=logging.WARNING,
default=settings.LOG_LEVEL,
)
parser.add_argument(
"-vv",
Expand Down Expand Up @@ -298,7 +298,12 @@ def main():
)
# log_format = "[%(asctime)s] p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s"

setup_handlers(args, log_format)
handlers = setup_handlers(args, log_format)
logging.basicConfig(
level=args.loglevel,
format=log_format,
handlers=handlers,
)

logging.getLogger("aiosqlite").setLevel(logging.WARNING)
logging.getLogger("sqlalchemy.engine").setLevel(logging.WARNING)
Expand Down
6 changes: 1 addition & 5 deletions src/aleph/vm/orchestrator/custom_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,4 @@ def setup_handlers(args, log_format):
non_execution_handler.setFormatter(
logging.Formatter("%(asctime)s | %(levelname)s %(name)s:%(lineno)s | %(message)s ")
)
logging.basicConfig(
level=args.loglevel,
format=log_format,
handlers=[non_execution_handler, execution_handler],
)
return [non_execution_handler, execution_handler]

0 comments on commit c2bc731

Please sign in to comment.