Improved logging for Bottle.
Project description
Improved logging for Bottle.
Use
In order to catch exceptions from other plugins the LoggingPlugin should be the first plugin you install to the application.
import bottle
from bottle_log import LoggingPlugin
app = bottle.Bottle()
app.install(LoggingPlugin(app.config))
@app.get('/test')
def test(logger):
logger.warning('This is only a test')
return {}
Configuration
The plugin uses the following configuration keys:
logging.level
The logging level. Possible values: debug, info, warning, error, critical. Defaults to warning.
logging.format
The logging format. See the python logging documentation for the format. Defaults to “[%(asctime)s] %(levelname)s: %(name)s: %(message)s”
logging.utc
If True, the default, time stamps are in UTC.
Logging
The standard logger, used by the logger keyword, prints to stderr by default.
Exception logging
This plugin also provides an exception logger (‘bottle.exception’). By default this logger does nothing, since bottle prints all exceptions to stderr, but it can be useful if you want to log exceptions to somewhere else. For example, logging to Logentries:
import bottle
from logentries import LogentriesHandler
from bottle_log import LoggingPlugin
app = bottle.Bottle()
app.install(LoggingPlugin(app.config))
le_handler = LogentriesHandler('logentries-api-token')
logging.getLogger('bottle.exception').addHandler(le_handler)
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
Hashes for bottle_log-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c549e3d1e612b7b8e7ed0ab684676b94007e764b5789cbb2c3eda0d4ae78e2ff |
|
MD5 | 3279f0a7793b6d5a55d468f9aae0b043 |
|
BLAKE2b-256 | 25d8825ccfebaf20cad9201e5961a05dcbb43834b653ae141a251cebd80b8ecf |