Skip to main content

A beautiful, colorful Python logging library by karenhoyoshi

Project description

logkaren

A beautiful, colorful Python logging library by karenhoyoshi

PyPI version Python License: MIT


Installation

pip install logkaren

Quick Start

from logkaren import Logger, Loader, Home, LogLevel

# Default ColorLogger
log = Logger()
log.info("Server started on port 8080")
log.success("User logged in successfully")
log.warning("Disk usage above 80%")
log.error("Connection refused")
log.debug("Variable x = 42")

# With timing
import time
start = time.time()
time.sleep(0.5)
end = time.time()
log.success("Task done", start=start, end=end)

# Ask user input
name = log.question("What is your name? ")

# Critical — pauses and exits
log.critical("Fatal error occurred", exit_code=1)

Logger Styles

Style 1 — ColorLogger (default)

log = Logger()           # or Logger(style=1)

Colorful output with pink prefix, magenta timestamps, and colored log levels.

Style 2 — SimpleLogger

log = Logger(style=2)

Clean minimal output — great for production or CI environments.


Constructor Options

Logger(
    style=1,                          # 1 = ColorLogger, 2 = SimpleLogger
    prefix="karenhoyoshi.asia",       # Custom prefix shown in brackets
    github_repository="github.com/karenhoyoshi/myproject",  # Shown on startup
    level=LogLevel.DEBUG,             # Minimum log level to display
    log_file="logs/app.log",          # Optional file to save logs
)

Log Levels

Level Value Description
DEBUG 1 Detailed debug information
INFO 2 General information
WARNING 3 Something unexpected but non-fatal
SUCCESS 4 Operation completed successfully
FAILURE 5 Operation failed
CRITICAL 6 Fatal error — exits the program
from logkaren import Logger, LogLevel

# Only show WARNING and above
log = Logger(level=LogLevel.WARNING)

Loader

Animated terminal spinner for long-running tasks.

from logkaren import Loader
import time

# As context manager (recommended)
with Loader(desc="Fetching data from API", end="Done fetching!"):
    time.sleep(3)

# Manual control
loader = Loader(desc="Processing files")
loader.start()
time.sleep(2)
loader.stop()

Options:

Param Default Description
prefix karenhoyoshi.asia Prefix shown in the spinner
desc Loading... Description text next to the spinner
end \r Message shown when done (or \r)
timeout 0.1 Speed of animation (seconds per frame)

Home Screen

Display a styled ASCII banner at startup.

from logkaren import Home

Home(
    title="MYAPP",
    subtitle="The coolest tool ever",
    credits="by karenhoyoshi",
    adinfo1="v2.0.0",
    adinfo2="github.com/karenhoyoshi/myapp",
    clear=True,   # Clear terminal before displaying
).display()

Requires pyfiglet for the big ASCII title font (installed automatically).


Logging to File

log = Logger(log_file="logs/app.log")
log.info("This will be saved to file too")

ANSI color codes are automatically stripped from file output.


License

MIT © karenhoyoshi

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

logkaren-1.0.3.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

logkaren-1.0.3-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file logkaren-1.0.3.tar.gz.

File metadata

  • Download URL: logkaren-1.0.3.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for logkaren-1.0.3.tar.gz
Algorithm Hash digest
SHA256 75987bbe979c7913e3166d32e9660bfa22b59893e42fc7cec36d6d6396316da8
MD5 7a8fed7f5d1824f6c3be6007eea978fc
BLAKE2b-256 a0c2df7e2350d16488e88e4e1fc2d25599511859bcb516113f63b4728d57081c

See more details on using hashes here.

File details

Details for the file logkaren-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: logkaren-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for logkaren-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7425ede94d88a68e06f5b68fa2b8d253484b6bd33844330544c7a0cad3f854dd
MD5 335fcdb5e9a4a82c03c782b5794f3a7d
BLAKE2b-256 77f8aa184cccecf936e741ad342c9efa9207fde7d1029f0e2a1c6b63675ada11

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