Skip to main content

Universal log files for Python

Project description


Pylogfile provides a better method for implementing logging in your Python scripts.

Core features:

  • automatically includes metadata such as timestamps.
  • supports optional detail strings to supplement the main log message.
  • integrated markdown makes it easy to highlight parts of log messages with color.
  • easily read and write logs to binary files for better efficiency, or JSON and TXT for best readability.
  • standardized format makes it easy to read previous log files, simplifying sorting and analysis.
  • script lumberjack makes viewing, sorting and analyzing log files quick and easy.

Pylogfile is designed to be a better option than the Python standard logging module for simple to intermediate-complexity logging tasks. For professional applications in which you want to add custom logging handlers, the standard module is the better choice. However, for the majority of scripts, especially in the scientific, engineering and data analysis domains, pylogfile offers loads of capability and a much faster way of setting up proper logging than the standard module. With pylogfile, your application has access to efficient data management and display through the addition of detailed messages, integrated markdown, and log search functions through the lumberjack script.

Installation

Pylogfile can be installed via pip using

pip install pylogfile

Example usage

In this example, we create a simple program that sends two log messages and saves them to disk. Here we show how to save to both binary and plain text formats. The HDF file format is binary, allowing logs to be saved faster and while using less space on disk. We also show how to save to a JSON file, for those who prefer the simplicity of plain text files.

from pylogfile.base import *

log = LogPile()
log.info("Something happened. Emphasize >this<.")
log.error("Something bad happened!")

log.save_hdf("example.log.hdf")
log.save_json("example.log.json")

With the corresponding output:

Lumberjack

Lumberjack is a command line interface (CLI) script included with pylogfile that allows log files to quickly be viewed, sorted, and analyzed. A log file can be opened in lumberjack with:

lumber example.log.hdf

and the first few logs displayed with the SHOW command:

Basic information about the log file can be displayed with the INFO command.

Logs can also be sorted by applying flags to the SHOW command. Here the --index flag is used to search based on the index of the log entry, the --contains flag is used to search for the keyword or phrase 'RF' while specifying a max of 5 logs should be displayed using the --num flag, and the log level is filter by applying the --min and --max flags.

Lumberjack has lots of other search functions, commands, and features. You can learn more about it from its integrated help menu which can list all available commands and provide detailed information on how to use them.

Documentation

Pylogfile's documentation can be found on ReadTheDocs.

Requirements

  • Python >= 3.9
  • numpy >= 1.0.0
  • h5py >= 3.11.0
  • colorama >= 0.4.6
  • importlib >= 1.0.0

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

pylogfile-0.3.1a0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

pylogfile-0.3.1a0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file pylogfile-0.3.1a0.tar.gz.

File metadata

  • Download URL: pylogfile-0.3.1a0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.4

File hashes

Hashes for pylogfile-0.3.1a0.tar.gz
Algorithm Hash digest
SHA256 5796e98d91ad700c50aa370b80af4e29c1724bbb2b0bf85ef6f0534aa1387540
MD5 84ffd4cfd4fbd5af59f6379c281cdcef
BLAKE2b-256 7e95d8b0156fae836e986bae32cd9d9f6e07705addcd40ba3e7fcf7d765891fa

See more details on using hashes here.

File details

Details for the file pylogfile-0.3.1a0-py3-none-any.whl.

File metadata

  • Download URL: pylogfile-0.3.1a0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.4

File hashes

Hashes for pylogfile-0.3.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 95868095f290cc97ec0c0a60a4a7356de8afe6e4f742e3991db1435a48c3b8f5
MD5 c181204085c86f58ab9265298db37963
BLAKE2b-256 bfb3e38315973f5621d65b87b3ae94b74c85cd49ac178469d1b30a2d894fac7a

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