当前位置:网站首页>超好用的日志库 logzero
超好用的日志库 logzero
2022-07-03 02:39:00 【strawberry47】
python自带的日志库实在是太难用了,一点都不简洁!
在朋友的安利下发现了这个超棒的logzero库,直接 .info就可以输出,输出还有颜色,文件 + 行号,超级方便!
它会自动输出日志到对应文件,搭配tmux使用,可以抛弃nohup命令了!
服务器小技能(alias, tmux, htop,gpustat, zsh)
import logzero
nowtime = datetime.datetime.fromtimestamp(time.time()).strftime("%Y_%m_%d-%H_%M_%S")
logger_path = os.path.join(config['ENV']['OUT_PUT'], "logs", "[Baseline]_{}.log".format(nowtime))
logzero.logfile(logger_path)
logzero.logger.info("output")
输出文件有时间、代码行等信息
from logzero import logger
# These log messages are sent to the console
logger.debug("hello %s", "world")
logger.info("info")
logger.warning("warn")
logger.error("error")
# This is how you'd log an exception
try:
raise Exception("this is a demo exception")
except Exception as e:
logger.exception(e)

边栏推荐
- GBase 8c系统表-pg_class
- Gbase 8C create user / role example 2
- Memory pool (understand the process of new developing space from the perspective of kernel)
- Can netstat still play like this?
- awk从入门到入土(3)awk内置函数printf和print实现格式化打印
- Gbase 8C function / stored procedure definition
- Gbase 8C system table PG_ cast
- GBase 8c系统表pg_cast
- require. context
- Gbase 8C system table PG_ amop
猜你喜欢

Awk from introduction to earth (0) overview of awk

A2L file parsing based on CAN bus (2)

Practice of traffic recording and playback in vivo

Build a private cloud disk cloudrev

SQL statement

The use of Flink CDC mongodb and the implementation of Flink SQL parsing complex nested JSON data in monggo

Memory pool (understand the process of new developing space from the perspective of kernel)

Add MDF database file to SQL Server database, and the error is reported
![[translation] modern application load balancing with centralized control plane](/img/b0/22e9bf098d580b2af67255ddcdc0d5.jpg)
[translation] modern application load balancing with centralized control plane

easyExcel
随机推荐
Gbase 8C system table PG_ constraint
Can netstat still play like this?
GBase 8c 创建用户/角色 示例二
Awk from introduction to earth (0) overview of awk
Wechat - developed by wechat official account Net core access
Gbase 8C system table PG_ cast
UDP receive queue and multiple initialization test
Producer consumer model based on thread pool (including blocking queue)
Gbase 8C system table PG_ class
Two dimensional format array format index subscript continuity problem leads to return JSON format problem
MUX VLAN Foundation
Add automatic model generation function to hade
Practice of traffic recording and playback in vivo
[fluent] futurebuilder asynchronous programming (futurebuilder construction method | asyncsnapshot asynchronous calculation)
[translation] modern application load balancing with centralized control plane
Face recognition 6-face_ recognition_ Py based on OpenCV, face detection and real-time tracking using Haar cascade and Dlib Library
Random Shuffle attention
cvpr2022去雨去雾
awk从入门到入土(0)awk概述
sql server 查询指定表的表结构