Skip to main content

A logging library for Python.

Project description

charlogger

A logging library for Python.

I've been using this myself for a while, and I thought that I may as well release it.

It's filled with bad code, but now that it is public, I'll probably improve it over time.

logger example

Installation

You can install charlogger with pip install charlogger.

How to use

Simple example

import charlogger

logger = charlogger.Logger()
logger.info("What a great logging library!")

Advanced example

import charlogger

# All parameters are optional.
logger = charlogger.Logger(
    debug=True, # Whether to enable the output of debug logs
    default_prefix="your prefix",
    color_text=False, # Whether to have the info text be colored
    log_file_patj=open("log.txt", "a"), # The file to put logs in
    indent_level=8, # The indentation of the text when output.
    centered=True # Whether to center text in the console.
)

logger.info("What a great logging library!")

My personal configuration (best)

import charlogger

logger = charlogger.Logger(
    debug=True,
    default_prefix="<TIME> | WORKER-001",
    color_text=True
)
logger.info("What a great logging library!")

More in-depth documentation

defaultPrefix

When initializing a Logger, you have the option of default_prefix.

For now, if you add "<TIME>" anywhere in that string, it will replace it with the time of the logging.

For instance, the following code will print 18:26:15 | hi! | i > What a great logging library!

import charlogger

logger = charlogger.Logger(
    debug=True,
    defaultPrefix="<TIME> hi!"
)
logger.info("What a great logging library!")

Logging methods

Possible arguments

import charlogger

logger = charlogger.Logger()
logger.info("What a great logging library!") # i > What a great logging library! 
logger.info(title="DOCUMENTATION", data="What a great logging library!") # i > [DOCUMENTATION] What a great logging library! 

All possible methods

import charlogger

logger = charlogger.Logger()
logger.info("What a great logging library!")
logger.warn("What a great logging library!")
logger.error("What a great logging library!")
logger.debug("What a great logging library!")
logger.valid("What a great logging library!")
logger.invalid("What a great logging library!")
logger.plus("What a great logging library!")
logger.paid("What a great logging library!")

Special methods

import charlogger

logger = charlogger.Logger()

# I can't imagine this one being all that useful. It's more there for my personal projects that use it,
logger.choice(1, "Option 1") # 1 > Option 1 

# Will wait for user input in the console.
name = logger.ask("What is your name?") # ? > What is your name? > 
print(name)

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

charlogger-1.2.1.tar.gz (3.4 kB view hashes)

Uploaded Source

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