Skip to content

Commit

Permalink
add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDaniel committed Feb 27, 2024
1 parent c35b4d9 commit a3b95f0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = ["virtualenv >= 20.25", "pydantic"] # add all the dependencies here
dependencies = ["virtualenv >= 20.25", "pydantic", "colorlog"] # add all the dependencies here
dynamic = ["readme", "version"]

[project.urls]
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#
annotated-types==0.6.0
# via pydantic
colorama==0.4.6
# via colorlog
colorlog==6.8.2
# via migmose (pyproject.toml)
distlib==0.3.8
# via virtualenv
filelock==3.13.1
Expand Down
22 changes: 22 additions & 0 deletions src/migmose/logger.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[loggers]
keys=root

[logger_root]
handlers=stream
level=DEBUG

[formatters]
keys=color

[formatter_color]
class=colorlog.ColoredFormatter
format=%(log_color)s%(levelname)-8s [%(name)s] %(message)s
datefmt=%H:%M:%S

[handlers]
keys=stream

[handler_stream]
class=StreamHandler
formatter=color
args=()
12 changes: 12 additions & 0 deletions src/migmose/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
This module provides a logger instance for migmose
"""

import logging.config
from pathlib import Path

# Construct the path to the configuration file
logger_config_file: Path = Path(__file__).with_suffix(".ini")

logging.config.fileConfig(logger_config_file)
logger = logging.getLogger("migmose")

0 comments on commit a3b95f0

Please sign in to comment.