DavesLogger
A simple but in depth logger for Python, Customize by Composition.
The idea for this tool is composing logging functions, so you can make the logs look exactly how you want or need them to.
Dave's logger3, but written in Python
Usage
You just import the package, and call log.
from DavesLogger import Log
Log ('Hello, World!') ()
# This would print:
# Hello, World!
That's not interesting, lets compose a simple prefix in front of the message.
from DavesLogger import Log
Prefixed = Log ().Prefix ('[DEBUG] ')
Prefixed ('Hello World, Debug Edition')
# This would print:
# [DEBUG] Hello World, Debug Edition
You can also chain the logging modifiers
from DavesLogger import Log
Prefixed = Log ().Prefix ('[DEBUG] ').Suffix (' [SUFFIX])
Prefixed ('Hello World, Debug Edition')
# This would print:
# [DEBUG] Hello World, Debug Edition [SUFFIX]
There are also a bunch of built in formatters, and colors. Colors are based on the colorama module, so you can use their api of chaining properties.
from DavesLogger import Log, Color
Prefixed = Log ().Prefix (Color.LightRed + '[DEBUG] ').Suffix (Color.LightGreen + ' [SUFFIX])
Prefixed (Color.Blue + 'Hello World, Debug Edition')
# This would print:
# [DEBUG] Hello World, Debug Edition [SUFFIX]
# But colored ^^
Or you can call some premade logs
from DavesLogger import Logs
MyLog = Logs.Debug
MyLog ()
# This would print:
# [DEBUG] DEBUG MESSAGE
# But colored ^^
You can event also change the text of premade logs!
from DavesLogger import Logs
MyLog = Logs.Debug
MyLog ('My custom debug message')
# This would print:
# [DEBUG] My custom debug message
# But colored ^^
Log Object
A log object has the following attributes:
- Message
- IPrefix
- ISuffix
And the following functions:
- Template
- Prefix
- Suffix
How the attributes work
from DavesLogger import Log
MyLog = Log ()
MyLog.Message = 'Hello!'
MyLog.IPrefix = '[Test] '
MyLog ()
# This would print:
# [Test] Hello!
The template function lets you load specific settings for your log
from DavesLogger import Log, Logs
MyLog = Log ().Template (Logs.Debug)
# This is the same as doing:
MyLog = Logs.Debug
The Prefix and Suffix function appends a new prefix or suffix to the current logs prefix or suffix.
Format
Format attributes:
- Time :: The current time
- Date :: The current date
- FullDate :: The current date and time
- Platform :: All info about the OS
- System :: The OS
- Release :: The release of the OS
- Version :: The version of the OS
Example use of the attribues:
from DavesLogger import Logs, Format
MyLog = Logs.Server.Prefix (f'[{Format.Time}] ')
MyLog ()
# This would print:
# [SERVER] [20:57:18.633029] SERVER MESSAGE
# But colored ^^
# *The time may vary!*
You can also use the Formats Format function
from DavesLogger import Logs, Format, Color
MyLog = Logs.Server.Prefix (Format.Format (f'[{Format.Time}] ', Color.Red))
MyLog ()
# This would print:
# [SERVER] [20:57:18.633029] SERVER MESSAGE
# But colored ^^
# *The time may vary!*
Colors
- Reset
- End (Same as Reset)
- White
- LightGray
- Gray
- Black
- Red
- LightRed
- Blue
- LightBlue
- Green
- LightGreen
- Yellow
- LightYellow
- Purple
- LightPurple
- Cyan
Premade Logs
- Debug ::
[DEBUG] DEBUG MESSAGE>> The Prefix is LightPurple - Warning ::
[WARNING] WARNING MESSAGE>> The Prefix is LightYellow - Error ::
[ERROR] ERROR MESSAGE>> The Prefix is LightRed - Success ::
[SUCCESS] SUCCESS MESSAGE>> The Prefix is LightGreen - Server ::
[SERVER] SERVER MESSAGE>> The prefix is LightBlue
Metadata
Release files for DavesLogger 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| DavesLogger-1.1.0.tar.gz | 4.6 kB | Without provenance | Details for DavesLogger-1.1.0.tar.gz |
Release files / DavesLogger-1.1.0.tar.gz
| Download URL | DavesLogger-1.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78fd03bc4eb843560eb631f50bafa2cae7c52f2ca4bb223e7ce4a5c1154f8476
|
|
BLAKE2b-256 checksum How to use checksums |
e32562a5d8ee2886b4eb4f7ba31704c5cc20b323c511fee1bd45fc06e5a6d473
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Security for DavesLogger 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.