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.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

tinLogging-0.0.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tinlogging-0.0.3.tar.gz
  • Upload date:
  • Size: 7.9 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.3.tar.gz
Algorithm Hash digest
SHA256 7218786df6d4db9a19d88ba5e15bd7c1de955b7f16ba0a16eb45ef36e8ec8269
MD5 5d25471aa5fdc76b41c4d0fedf9fe412
BLAKE2b-256 2a8708a83f0fd8db75fa6019c7624ac3651a54fe26bfa6d25d40d17740847f7b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tinLogging-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cda3009b9a19a06aba1abb7d9c4e7678e0edd9c18834010af2036eb46349a7a8
MD5 66cd8679f53d90c20889b796f40e34ce
BLAKE2b-256 861c81e983291fd7ef5bc334034120d8ba3e851e5f6a0e267d6be7679ee6c451

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