added example, edited readme
This commit is contained in:
parent
e7d17019e3
commit
104c80160b
26
README.md
26
README.md
@ -1,26 +1,30 @@
|
|||||||
# sanelogging
|
# sanelogging
|
||||||
|
|
||||||
## Sane defaults for python logging
|
## Sane Defaults for Python Logging
|
||||||
|
|
||||||
The python stdlib `logging` module is useful, flexible, and configurable.
|
The python stdlib `logging` module is useful, flexible, and configurable.
|
||||||
|
|
||||||
However, the maintainers reasonably have determined that python is an
|
However, the maintainers have (quite reasonably) determined that python is an
|
||||||
application runtime and not an application. The default configuration
|
application runtime and not an application. The default configuration
|
||||||
for the `logging` is not very useful, and this results in boilerplate.
|
for the `logging` is thus not very useful, and this commonly results in
|
||||||
|
boilerplate in your own programs.
|
||||||
|
|
||||||
This is an opinionated module for the 90% case where you just want sane
|
This is an opinionated module for the 90% case where you just want sane
|
||||||
defaults. (In effect, moving the boilerplate into PyPI.)
|
defaults without that boilerplate. (In effect, moving it into PyPI.)
|
||||||
|
|
||||||
# Other Stuff
|
# It Also Does Some Other Stuff
|
||||||
|
|
||||||
There are some convenience methods added, such as `panic` and `die` (c.f.
|
* There are some convenience methods added, such as `panic` and `die` (c.f.
|
||||||
golang and perl).
|
golang and perl).
|
||||||
|
|
||||||
`notice` is additionally aliased to `info`, for those who forget that python
|
* `notice` is aliased to `info`, for those who forget that python
|
||||||
doesn't have a notice level (i.e. me).
|
doesn't have a notice level (i.e. me).
|
||||||
|
|
||||||
If you set the environment variable `LOG_TO_SYSLOG`, it will print out your
|
* If you set the environment variable `LOG_TO_SYSLOG`, it will print out your
|
||||||
log messages on paper and mail them to you.
|
log messages on paper and mail them to you.
|
||||||
|
|
||||||
|
* If stdout is a tty, log messages will be color-coded using the `colorlog`
|
||||||
|
module.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
|
BIN
example/example.png
Normal file
BIN
example/example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
10
example/example.py
Normal file
10
example/example.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from sanelogging import log
|
||||||
|
|
||||||
|
log.info("starting up!")
|
||||||
|
|
||||||
|
log.error("something went wrong.")
|
||||||
|
|
||||||
|
log.die("bailing out") # exits
|
||||||
|
|
Loading…
Reference in New Issue
Block a user