Add dynamic log level #1

Merged
Kim merged 6 commits from python3.10 into master 2022-08-13 12:30:22 +02:00
Owner

Possible values

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

  • debug
  • info
  • warn
  • warning
  • crit
  • critical

Requirements

  • Python 3.10 or higher

Usage example

# 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
## Possible values Values can be set case insensitive (DEBUG, debug, Debug). - debug - info - warn - warning - crit - critical ## Requirements - Python 3.10 or higher ## Usage example ```python # 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 ```
Kim added the
enhancement
label 2022-08-13 12:28:33 +02:00
Kim self-assigned this 2022-08-13 12:28:33 +02:00
Kim added 6 commits 2022-08-13 12:28:35 +02:00
Add dynamic log level handling
Some checks failed
continuous-integration/drone/push Build is failing
2626ceead6
Fix _logger assignment
All checks were successful
continuous-integration/drone/push Build is passing
ed35590ac6
Change step name
All checks were successful
continuous-integration/drone/push Build is passing
ddca0fee38
Add prepare step
Some checks failed
continuous-integration/drone/push Build is failing
4337306497
Revert "Add prepare step"
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
74876c1231
This reverts commit 43373064975888cacecb9d79af32b0f7226eef3a.
Add Requirements section
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
e3dff0c61b
Kim merged commit 16820fa083 into master 2022-08-13 12:30:22 +02:00
Kim referenced this issue from a commit 2022-08-13 12:30:22 +02:00
Kim deleted branch python3.10 2022-08-13 12:30:32 +02:00
Sign in to join this conversation.
No Reviewers
No Milestone
No project
No Assignees Kim
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Kim/logger.py#1
No description provided.