Simple logger function
Go to file
Kim Oliver Drechsel 746aaa6c2a
All checks were successful
continuous-integration/drone/push Build is passing
Update Readme.md
2022-08-13 12:37:57 +02:00
.drone.yml Add dynamic log level (!1) 2022-08-13 12:30:20 +02:00
.gitignore add .idea to .gitignore 2021-08-07 20:25:23 +02:00
LICENSE update LICENSE 2021-10-07 10:58:24 +02:00
loghandler.py Add dynamic log level (!1) 2022-08-13 12:30:20 +02:00
README.md Update Readme.md 2022-08-13 12:37:57 +02:00
requirements.txt Update colorlog version 2021-12-07 12:02:49 +01:00

logger.py

Build Status

Simple logger function with colored LogLevel designed to run inside Docker container

Possible values

Values can be set case insensitive (DEBUG, debug, Debug).

  • debug
  • info (default value)
  • warn
  • warning
  • crit
  • critical

Requirements

  • Python 3.10 or higher

Usage example

Use the environment variable LOG_LEVEL to set the log level.

LOG_LEVEL = debug

# Setting LOG_LEVEL with `os.environ` is only necessary if environment variable has not been set before (e.g. outside Docker)
import os
os.environ['LOG_LEVEL'] = 'DEBUG'

from loghandler import logger

def main():
    logger.debug("This is a Debug Message")
    logger.info("This is a Info Message")
    logger.warning("This is a Warning Message")
    logger.error("This is a Error Message")
    logger.critical("This is a Critical Message")

main()
[Fri, 06 Aug 2021 13:36:09] DEBUG [test.py.main:7] This is a Debug Message
[Fri, 06 Aug 2021 13:36:09] INFO [test.py.main:8] This is a Info Message
[Fri, 06 Aug 2021 13:36:09] WARNING [test.py.main:9] This is a Warning Message
[Fri, 06 Aug 2021 13:36:09] ERROR [test.py.main:10] This is a Error Message
[Fri, 06 Aug 2021 13:36:09] CRITICAL [test.py.main:11] This is a Critical Message

Credits

Repo Icon made by Smartline from www.flaticon.com