Logging boilerplate for the command line
Project description
basecmd
Boilerplate for the command line.
Classes inheriting from BaseCmd have a self.log attribute
that is a standard Python logger. A basic logging configuration to sys.stdout
is provided.
For command line options controlling the logging verbosity
and output to a log file, call the command with -h or --help.
Defaults for logging options can be also provided as environment variables
or in a .emv file:
LOG_LEVEL: the logging verbosity, one oferror,warn,info, ordebug; default:info. 'LOG_FILE: path to a log file, defaults to the standard output for easy redirection.LOG_FORMAT: a standard Python logging format, defaults to%(asctime).19s %(message)swhen logging to a file or a terminal and%(message)sotherwise.
When logging to a terminal, the output is colored by log level.
Example usage
from basecmd import BaseCmd
class MyCmd(BaseCmd):
def add_arguments(self):
self.parser.add_argument('--foo',
help='Custom command line option')
def __call__(self):
self.log.debug(self.options.foo)
if __name__ == '__main__':
cmd = MyCmd
cmd()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basecmd-0.0.0.tar.gz.
File metadata
- Download URL: basecmd-0.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58ed46bb138c49923bf7cf12772b9e7b0bcff710fc92576ee430f6f9668965b1
|
|
| MD5 |
c4159e5974c88b45c07a4ce8e7d17583
|
|
| BLAKE2b-256 |
b4e41122abd44fc78fbbbc412630f19f3f008179b5d1d2f0dc5842826a19d9e5
|
File details
Details for the file basecmd-0.0.0-py3-none-any.whl.
File metadata
- Download URL: basecmd-0.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f560080db953a2b45c2c0e0ad5a68adc4926a089c8b889f15380451a3cb4195
|
|
| MD5 |
84112a62a6f06acbdac53f73f41f115b
|
|
| BLAKE2b-256 |
d2df89ba86cfc6f9513f8459b33b31b85843e8e838ffc5cd80f00aaa64fa89a3
|