🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

openlog

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openlog

Open-source minimal Rich-based logging solution

1.0.0
PyPI
Maintainers
1

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")

# 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

License

MIT License

Keywords

logs

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts