Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a0632c93 authored by Florent Bouchez Tichadou's avatar Florent Bouchez Tichadou
Browse files

Merge branch 'dev/noe/log' into 'main'

Fixed logs for arcade & easytracker

See merge request !88
parents 59961891 96b20927
No related branches found
No related tags found
1 merge request!88Fixed logs for arcade & easytracker
......@@ -159,16 +159,16 @@ Normally, at this step, all should work correctly:
## Dependencies
To test Agdbentures, you will need `pytest` and `criterion`.
To test Agdbentures, you will need `pytest`, `pytest-env` and `criterion`.
```console
apt install libcriterion3 python3-pytest
apt install libcriterion3 python3-pytest python3-pytest-env
```
or, in the venv (only for pytest):
```console
pip install pytest
pip install pytest pytest-env
```
......
......@@ -161,16 +161,16 @@ if __name__ == "__main__":
set_loggers_level(loglevel)
# only warning logging for the following modules
modules = ["PIL"]
if args.easy_debug is None:
modules.append("easytracker")
if args.arcade_debug is None:
modules.append("arcade")
for lgn in modules:
lg = logging.getLogger(lgn)
lg.setLevel(level=logging.WARNING)
# only warning logging by default for the following modules
modules_debug = {'PIL': None, 'arcade': args.arcade_debug, 'easytracker': args.easy_debug}
for module, debug_module in modules_debug.items():
module_logger = logging.getLogger(module)
if debug_module:
module_log_level = loglevel
else:
module_log_level = logging.WARNING
module_logger.setLevel(module_log_level)
# launch code visu window and register exit function to close the window
if args.no_code:
......
import logging
import os
class Colors:
......@@ -34,9 +35,7 @@ class ColoredFormatter(logging.Formatter):
class ColoredLogger(logging.Logger):
def __init__(self, name):
logging.Logger.__init__(self, name, level=logging.WARNING)
self.parent = logging.root
self.propagate = True
logging.Logger.__init__(self, name)
formatter = ColoredFormatter()
......@@ -50,10 +49,12 @@ def get_loggers():
# /!\ using basicConfig will result in duplicated lines of log
def set_loggers_level(loglevel):
"""substitute for basicConfig"""
logging.getLogger().setLevel(loglevel)
for l in get_loggers():
l.setLevel(loglevel)
logging.setLoggerClass(ColoredLogger)
if "AGDB_LOGS_NO_COLOR" not in os.environ or os.environ["AGDB_LOGS_NO_COLOR"] != "1":
logging.setLoggerClass(ColoredLogger)
log = logging.getLogger("agdb")
cus = logging.getLogger("custom")
......
......@@ -49,7 +49,7 @@ sys.path.insert(0, os.path.join(cdir, "lib"))
sys.path.insert(0, os.path.join(cdir, "easytracker"))
from loader.loader_utils import extract_metadata, apply_unifdef, get_defines, strip_comments
from logs import mklog, set_loggers_level
from logs import mklog
AGDBENTURES_DIR = os.path.dirname(__file__)
ENGINES_DIRS = os.path.join(AGDBENTURES_DIR, "engine_versions")
......@@ -154,7 +154,7 @@ elif args.debug == 2:
else:
loglevel = logging.DEBUG
set_loggers_level(loglevel)
mklog.setLevel(loglevel)
# In test mode, should always clear first the directory to ensure we use the
# latest version
......
......@@ -5,3 +5,6 @@ addopts= --ignore=easytracker
pythonpath = lib/ .venv/lib/python3.11/site-packages/
testpaths = lib/tests/manual lib/tests/auto lib/tests/easytracker
; Deactivated tests for now
env =
AGDB_LOGS_NO_COLOR=1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment