改进了瓶子的记录。

bottle-log的Python项目详细描述


改进了瓶子的记录。

使用

为了捕获其他插件的异常,loggingplugin应该是 安装到应用程序的第一个插件。

importbottlefrombottle_logimportLoggingPluginapp=bottle.Bottle()app.install(LoggingPlugin(app.config))@app.get('/test')deftest(logger):logger.warning('This is only a test')return{}

配置

该插件使用以下配置键:

logging.level

日志级别可能值:调试信息警告错误关键。 默认为警告

日志记录。格式

日志记录格式。有关格式,请参阅python日志记录文档。 默认为“[%(asctime)s]%(levelname)s:%(name)s:%(消息)s

logging.utc

如果true,则默认时间戳以UTC为单位。

日志记录

默认情况下,由logger关键字使用的标准记录器将打印到stderr

异常日志记录

这个插件还提供了一个异常记录器(“bottle.exception”)默认情况下 这个记录器什么也不做,因为bottle将所有异常都打印到stderr,但是它可以 如果要将异常记录到其他地方,则此选项非常有用。 例如,记录到日志条目:

importbottlefromlogentriesimportLogentriesHandlerfrombottle_logimportLoggingPluginapp=bottle.Bottle()app.install(LoggingPlugin(app.config))le_handler=LogentriesHandler('logentries-api-token')logging.getLogger('bottle.exception').addHandler(le_handler)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java:关于Eclipse的几个问题   java在Apache Camel Netty组件中使用SSL,并带有JVM默认密钥库文件   Java解析未格式化字符串   java前缀字符串资源标识符,用于在运行时选择备用版本   java为什么三元表达式在if语句正常工作时不更新值?   java我需要帮助程序以特定格式输出文本文件。   java Spring Tomcat启动问题setCatalinaBase(Ljava/io/File;)   递归java数独回溯递归   java如何解决构造函数上的错误?   getEngineByName(“JavaScript”)在Java 11上返回null   java如何将对象添加到数组并打印它?   java我在层泄漏反模式中吗?我该怎么办?   java动态移动带有ImageIcon的JLabel时,会在帧周围跳跃   JavaXSLT转换释放了特殊字符   java BuffereImage会降低性能   DL4J中的java回归预测下一个时间步   Java 11中的spring boot复制JAR导致以下错误   如何通过编程将图像编码到Java视频文件中?   如何使用Java更新Pentaho转换连接数据?