Skip to main content

Simple, performant logging with ANSI colors for Python.

Project description

ezlog

Simple, performant logging with ANSI colors for Python.
Published on PyPI as ezlog-py.

  • 6 levels: debug, info, success, warn, error, critical
  • Short aliases: d, i, s, w, e, c
  • ANSI colors: full palette
  • Stdlib integration: creating an EzLog wires it to stdlib logging automatically
  • Zero dependencies

Install

pip install ezlog-py

Usage

Create a logger; it wires itself to stdlib logging. Use log.i(), log.success(), and anywhere logging.info() / logger.error() also go through ezlog:

from ezlog import EzLog

log = EzLog()  # or EzLog({"useColors": True, "timestamp": False})

# Direct ezlog (includes .success() level)
log.success("Application started")
log.i("Hello")
log.w("Oops")
log.e("OMG")
log.d("hmmm..")

# Stdlib logging (wired internally; same formatting)
import logging
logging.info("From stdlib")
logging.error("Failed", exc_info=True)

Configuration

# Example: custom config (partial overrides)
log = EzLog({
    "useColors": True,
    "useLevels": True,
    "useSymbols": False,
    "textColor": "white",
    "bracesColor": "light-white",
    "stdlibLevel": "INFO",
    "timestamp": {
        "color": "white",
        "format": "%Y-%m-%d %H:%M:%S",
    },
    "levels": {
        "info": {"text": "Information"},
        "debug": isDevelopment, # disable debug in production
        "critical": False,      # or disable a level entirely
    },
})

Each option has a default and is optional.

  • useColors : boolean – Enable ANSI colors. Default True.
  • useLevels : boolean – Show level label/symbol in output. Default True.
  • useSymbols : boolean – Use symbol for level (if False, use text label). Default True.
  • textColor : LogColors – define text color (e.g. "light-red", "cyan"). Default white.
  • bracesColor : LogColors – define braces color (e.g. "light-red", "cyan"). Default light-white.
  • timestamp : TimestampConfig or False – Configure timestamp, or set to False to disable.
  • levels : LevelsConfig – Keys: debug, info, success, warn, error, critical. Each value is a LevelConfig (partial override) or False to disable that level.
  • stdlibLevel : StdLevel – Root stdlib logging threshold used by ezlog wiring. StdLevel accepts: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL" (case-insensitive), ezlog level names ("debug", "warn", etc.), or a numeric stdlib level.

LevelConfig

  • color : LogColors – Level color (e.g. "light-red", "cyan").
  • text : str – Level label (e.g. "INFO", "Error").
  • symbol : str – Level symbol; validated with a safe fallback when the system doesn’t support the character.

TimestampConfig

  • format : str – strftime format (e.g. "%Y-%m-%d %H:%M:%S"). Default from ezlog.defaults.DEFAULT_TIMESTAMP_FORMAT.
  • color : LogColors or "as_levels" – Timestamp color. "as_levels" uses the same color as the log level. Default "as_levels".

Module / contextual segments

You can create logger "views" with additional prefixed segments, useful to tag modules, subsystems, or request scopes, without reconfiguring the global logger:

from ezlog import EzLog, add_segments

base_log = EzLog({"useColors": True, "timestamp": {"color": "as_levels"}})

# Per-module logger (LogicModule)
logic_log = base_log.with_segments([
    {"text": "LogicModule", "color": "as_levels"},
])

# Or using the helper function:
api_log = add_segments(base_log, [
    {"text": "API", "color": "as_levels"},
])

logic_log.i("message from logic module")
api_log.i("message from API layer")

Output example:

[2026-03-12 11:36:28] [LogicModule] [i] message from logic module
[2026-03-12 11:36:29] [API] [i] message from API layer

Segments use the same color system as timestamps: "color": "as_levels" reuses the level color, or you can pass any LogColors value.

Levels

  • Order (severity): debuginfosuccesswarnerrorcritical.
  • Short aliases: d, i, s, w, e, c.
  • Stdlib mapping: logging.DEBUG → debug, logging.INFO → info, logging.WARNING → warn, logging.ERROR → error, logging.CRITICAL → critical. NOTSET is skipped.
  • Default symbols and colors are in ezlog.defaults (DEFAULT_TEXTS, DEFAULT_COLORS, DEFAULT_SYMBOLS_FALLBACK).

Runtime stdlib level control

You can control how much stdlib logging gets through ezlog:

import logging
from ezlog import EzLog

log = EzLog({"stdlibLevel": "INFO"})  # suppress stdlib DEBUG by default
logging.debug("hidden (filtered by stdlibLevel=INFO)")
logging.info("visible (passes stdlibLevel=INFO)")

log.set_stdlib_debug(True)     # DEBUG
log.set_stdlib_debug(False)    # INFO

log.set_stdlib_level("ERROR")  # threshold by name
log.set_stdlib_level(logging.WARNING)  # threshold by numeric level

Color properties

When useColors is enabled, the logger exposes:

Standard colors Light colors
log.red log.light_red
log.yellow log.lyellow
log.cyan log.lcyan
log.green log.lgreen
log.magenta log.lmagenta
log.blue log.lblue
log.white log.lwhite
log.black
log.gray

Use them for custom formatted output; end colored segments with log.reset.

Exports

  • EzLog(config?) – Create logger (wires to stdlib on construction). Config optional: EzLog() or EzLog({"useColors": True, "timestamp": False}).
  • TypesLogLevel, LogColors, TimestampColor, TimestampConfig, SegmentConfig, EzlogConfig, LevelsConfig, LevelConfig, LogArgs, ConsoleMethod.
  • Constants (from ezlog.defaults) – COLOR_CODES, RESET, DEFAULT_SYMBOLS_FALLBACK, DEFAULT_TEXTS, DEFAULT_COLORS, DEFAULT_TIMESTAMP_FORMAT, DEFAULT_TIMESTAMP_COLOR, DEFAULT_TIMESTAMP.

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

ezlog_py-1.0.9.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

ezlog_py-1.0.9-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file ezlog_py-1.0.9.tar.gz.

File metadata

  • Download URL: ezlog_py-1.0.9.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ezlog_py-1.0.9.tar.gz
Algorithm Hash digest
SHA256 ac17136035fd0aef4991433bfd504f39a02ccb4b460a06273e31db0718a47e91
MD5 3dfa559ab7facde106cc8fc6dbd598d3
BLAKE2b-256 e039cc1d5ede4143144615db9d910a8d5f3d1f3d158bcf142b4dc9dd69282f89

See more details on using hashes here.

File details

Details for the file ezlog_py-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: ezlog_py-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ezlog_py-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 320890a2849e89c1098ed01fc731e9cad876b9a3bf8822391457fefd61b549e7
MD5 bc81138fcbeb66203b6b41fb3043a5b4
BLAKE2b-256 c76d359fbc6b34256f1dd5e33f9aa41a765c95a18494c074cb504f8b61c1e8d8

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