Skip to main content

Open-source minimal Rich-based logging solution

Project description

OpenLog

A versatile Python logging utility with rich console output and file logging capabilities.

Features

  • Color-coded console output using Rich
  • Optional file logging with session-based or persistent log files
  • Multiple log levels (INFO, ERROR, WARN, INIT)
  • In-memory log storage with flush capability

Installation

pip install openlog

Quick Start

from openlog import Logger

# Basic console-only logger
logger = Logger()
logger.log("This is an info message")
logger.error("Something went wrong")
logger.warn("This is a warning")
logger.init("System initialized")

# Logger with file output
file_logger = Logger(write_to_file=True)
file_logger.log("This message goes to console and file")

# Session-based logging (new log file for each session)
session_logger = Logger(write_to_file=True, session=True)
session_logger.log("Logged with timestamp in filename")

# Store logs in a specific directory
dir_logger = Logger(in_dir=True, write_to_file=True)
dir_logger.log("Logs stored in /logs directory")

# Using custom prefixes for better log organization
module_logger = Logger(prefix="DATABASE")
module_logger.log("Connected to database")  # Will show as "[DATABASE] Connected to database"

# Retrieve logs programmatically
logs = file_logger.flush_logs()
all_logs = file_logger.flush_logs(from_start=True)

Log Levels

  • log() - General information (blue)
  • error() - Error messages (red)
  • warn() - Warning messages (yellow)
  • init() - Initialization messages (purple)

Configuration

The Logger class accepts the following parameters:

  • in_dir (bool): Store logs in a '/logs' directory
  • session (bool): Create unique log files with timestamps
  • write_to_file (bool): Enable file logging
  • prefix (str): Optional prefix added to all log messages (e.g., module name, component identifier)

License

MIT License

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

openlog-1.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

openlog-1.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file openlog-1.1.0.tar.gz.

File metadata

  • Download URL: openlog-1.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for openlog-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2c8f00654cee2c13a779fdabf7db1c63600ff4a6658d74b505556babd9807a40
MD5 f34e85dfd8aeb3ed0efa9d8d559eea3d
BLAKE2b-256 5cb14d486cdad3945bd726a29ee4d5f6af3a97ca46d8190ec36ade70af49aee4

See more details on using hashes here.

File details

Details for the file openlog-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: openlog-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for openlog-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb982de872515b7c1bfe398eb4a9b46a3e84f34d42061bd6b84d8fd88199a4cd
MD5 b566c3e53550794c602aca64ee774950
BLAKE2b-256 1a73ef5acfe857487d880c926f497152a6418874cfbd4d1815d15dc1957df4d7

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