Skip to main content

Python library for convenient and beautiful logging of information

Project description

PyPI version Python versions License GitHub stars GitHub release date

tinLogging

tinLogging is a versatile logging library for Python that provides a range of functionalities to enhance your application's logging capabilities

Installation

pip install tinLogging

Update

pip install --upgrade tinLogging

Quick start

from tinLogging import Logger, ConsoleLogger

logger = Logger(filename='log.txt', level='DEBUG', buffer_size=10, log_format='[%time] - %lvl | %text')
console_logger = ConsoleLogger(level='DEBUG', log_format='%time | %lvl | %text')
# Writing a log to a file 'log.txt'
logger.debug('This is a debug message')
# Log output to the console
console_logger.debug('This is a debug message')
console_logger.info('This is an info message')
console_logger.warning('This is a warning message')
console_logger.error('This is an error message')

This is what the color text output looks like in the console: Console Output

Logging to a file

Main functions

from tinLogging import Logger

logger = Logger(filename='log.txt', level='DEBUG', buffer_size=10, log_format='[%time] - %lvl | %text')
# Enabling automatic file rotation with zip archiving
logger.rotate_logs(max_megabytes_size=1, zip_compression=True, auto_rotate=True)
# Sending a log
logger.critical('This is a critical message')
# Creating a new log level with priority 3
logger.new_level(level_name='MyNewLevel', level_priority=3)
# Sending a log with a new level
logger.log('MyNewLevel', 'This is a MyNewLevel message')
# Deleting the old log level
logger.del_level('WARNING')

Additional functions

Export

logger.export_json(export_file='my_export_log.json')
logger.export_html(export_file='my_new_export_log.html')

Search and filtering

# Text search
search = logger.search_logs('message')
# Filtering by level
filter_logs = logger.filter_logs('CRITICAL')

Statistics

logger.log_stats(files_name='log.txt')

Archiving

logger.archive_logs(archive_name='my_zip_log.zip')

Checking for acceptable file size

logger.monitor_log_size(max_megabytes_size=8)
# Returns True if it exceeds the specified size

Buffer

# buffer_size - buffer size for optimizing I/O requests
logger = Logger(filename='log.txt', level='DEBUG', buffer_size=10, log_format='[%time] - %lvl | %text')
# Recording the remaining logs in the buffer
logger.close()

Logging to a Console

Logging into the console will allow you to display colored logs to facilitate the search for the necessary logging levels. But do not forget that after restarting the interpreter, the console is cleared

from tinLogging import ConsoleLogger
# You can customize the colors to suit your taste, but by default there are always the most suitable colors
logger = ConsoleLogger(level='DEBUG', log_format='%time | %lvl | %text', debug_color='standard', info_color='green')
# Creating a new log level
logger.new_level('HTTP', 4)
# Logging with the HTTP level highlighted in green
logger.log(level='HTTP', message='Code 200 - the site is working', color='green')

Contributing

We welcome contributions to the tinLogging project! If you have any bug reports, feature requests, or pull requests, please feel free to submit them on our GitHub repository

License

tinLogging is licensed under the MIT License. See the LICENSE file for more information

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

tinlogging-0.0.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

tinLogging-0.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file tinlogging-0.0.2.tar.gz.

File metadata

  • Download URL: tinlogging-0.0.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tinlogging-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e53cd02164d0ae0a5935e44cde96252c95d308580dd4dcafe91eedd5f6e3280a
MD5 1ef2bcde847885479d1bd11b61792e60
BLAKE2b-256 ebd19b8a5ece27e830d4d7112288fff794f2d8318c53955e60c6d8da6e615926

See more details on using hashes here.

File details

Details for the file tinLogging-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: tinLogging-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tinLogging-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64caa510736fe8211e51131b05c5325291a658be53bc708c78a5b1ed7b6069dd
MD5 da5d6ec7ff91bc5b62a5ba2444073245
BLAKE2b-256 70d18200230e7328956a2a2d6289d3363fee296e13c516ba242b1d07d5e46532

See more details on using hashes here.

Supported by

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