Skip to main content

A native python3 logging module for quickly setting up and managing logs.

Project description

logger

Tests

An easy-to-use logger class built using python3's native logger library. It can intelligently handle pushing stdout messages between files/terminals based off configured options. Extremely useful for setting up a whole logger.Logging() instance without worrying about configuring format/file-handling for scripts/applications.

Features

  • Has a built-in logging style: [DATE TIME] [LEVEL] [LOG NAME] [LOG COUNT] - [MESSAGE]
  • supports python's built-in with() statement
  • Can figure out whether to log a specific message to a file or log based off the Level configured such as:
    • Level 0/None - Log everything to the terminal.
    • Level 1 - Log critical to file. Log warnings/ok/info to terminal.
    • Level 2 - Log critical/error to file. Log warnings/info/ok to terminal.
    • Level 3 - Log errors/warnings to file. Log INFO/OK the terminal
    • Level 4 - Log everything into file
  • Dynamically switch log levels and logging files with set_log_file() and set_log_level() respectively.
  • Enable/Disable logging as needed.

Installation(Requires python >= 3.10)

pip3 install logger-henryriveracs==0.3.0 OR copy src/logger/logger.py into your repository.

Usage

#python3
from logger.logger import Log
items = ["item1", "item2", "item3", "item4", "item5"]

my_logger = Log(Name="My Logger")

my_logger.info(items[0])
my_logger.ok(items[1])
my_logger.warning(items[2])
my_logger.error(items[3])
my_logger.critical(items[4])

# pointing logger to example.log with log level set to 2
my_logger.set_log_file("example.log")
my_logger.set_log_level(2)
my_logger.ok("Test OK")
my_logger.error("Test Error")

Results from running example.py under the example/ folder

Terminal:

Image of example.py logger results for the terminal

File:

Image of example.py logger results for the terminal

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logger_henryriveracs-0.3.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logger_henryriveracs-0.3.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file logger_henryriveracs-0.3.1.tar.gz.

File metadata

  • Download URL: logger_henryriveracs-0.3.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for logger_henryriveracs-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7441c583ee3182125f7954ae15aab715bf27efbb15d335adc0b788373268c3c6
MD5 fe5b633d85474cf836baa469d07306aa
BLAKE2b-256 543b78c464f47210eeebefed226fc42a0a6584123cf08379216f4dc9c4dcbd4d

See more details on using hashes here.

File details

Details for the file logger_henryriveracs-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for logger_henryriveracs-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75dc1fda78b645ae71eb0445449e034309a44c1523938369a9c6abff039fae0c
MD5 0e4a598acc00c28542a52d0d2c9c09fd
BLAKE2b-256 42280bf5f3434563576bf5a9cfd57f6b713fc71c3eacfe1adc61f961f3992be0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page