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.
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
File details
Details for the file charlogger-1.2.1.tar.gz
.
File metadata
- Download URL: charlogger-1.2.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3c461c7868d5c2a46353c0978d1a5ff92a53d7a6bce1b03a6cf8e6ceb97ee62 |
|
MD5 | d5f62fb91b4a9bc7c0861334da3c254a |
|
BLAKE2b-256 | 6d5dff7564da36ccbb61a729e68dbaf65ae6757bbc8ebed2c129aa2f9b4f7843 |