tornado.log — Logging support¶
Logging support for Tornado.
Tornado uses three logger streams:
- tornado.access: Per-request logging for Tornado’s HTTP servers (andpotentially other servers in the future)
- tornado.application: Logging of errors from application code (i.e.uncaught exceptions from callbacks)
- tornado.general: General-purpose logging, including any errorsor warnings from Tornado itself.
These streams may be configured independently using the standard library’slogging
module. For example, you may wish to sendtornado.access
logsto a separate file for analysis.
Key features of this formatter are:
- Color support when logging to a terminal that supports it.
- Timestamps on every log line.
- Robust against str/bytes encoding problems.
This formatter is enabled automatically bytornado.options.parse_command_line
ortornado.options.parse_config_file
(unless—logging=none
is used).
参数: |
---|
- color (bool) – Enables color support.
- fmt (string) – Log message format.It will be applied to the attributes dict of log records. Thetext between %(color)s and %(end_color)s will be coloreddepending on the level if color support is on.
- colors (dict) – color mappings from logging level to terminal colorcode
- datefmt (string) – Datetime format.Used for formatting (asctime) placeholder in prefix_fmt.
在 3.2 版更改: Added fmt
and datefmt
arguments.
tornado.log.
enablepretty_logging
(_options=None, logger=None)[源代码]¶
Turns on formatted logging output as configured.This is called automatically by
tornado.options.parse_command_line
andtornado.options.parse_config_file
.
tornado.log.
definelogging_options
(_options=None)[源代码]¶
Add logging-related flags tooptions
.These options are present automatically on the default options instance;this method is only necessary if you have created your own
OptionParser
.4.2 新版功能: This function existed in prior versions but was broken and undocumented until 4.2.
原文: