Setup logging
(args, conf)
| 187 | |
| 188 | |
| 189 | def setup_logging(args, conf): |
| 190 | """Setup logging""" |
| 191 | logging_format = "%(asctime)s [%(levelname)s]: %(name)s (%(module)s.%(funcName)s; " \ |
| 192 | "%(filename)s:%(lineno)d)\n %(message)s" |
| 193 | |
| 194 | if getattr(args, "verbose", None): |
| 195 | debug_logger = logging.StreamHandler(sys.stdout) |
| 196 | debug_logger.addFilter(LogLevelFilter(max_level=logging.WARNING)) |
| 197 | debug_logger.setFormatter(logging.Formatter(logging_format)) |
| 198 | logging.root.addHandler(debug_logger) |
| 199 | logging.root.level = logging.DEBUG |
| 200 | |
| 201 | error_logger = logging.StreamHandler(sys.stderr) |
| 202 | error_logger.addFilter(LogLevelFilter(min_level=logging.ERROR)) |
| 203 | error_logger.setFormatter(logging.Formatter(logging_format)) |
| 204 | logging.root.addHandler(error_logger) |
| 205 | |
| 206 | if conf['logging']: |
| 207 | logging.config.dictConfig(conf['logging']) |
| 208 | |
| 209 | |
| 210 | CAPTURE_EXCEPTIONS = "I agree." |