当前位置:网站首页>超好用的日志库 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)
边栏推荐
- [Hcia]No.15 Vlan间通信
- 【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)
- [principles of multithreading and high concurrency: 1_cpu multi-level cache model]
- Simple understanding of SVG
- [fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
- Matlab tips (24) RBF, GRNN, PNN neural network
- QT qcombobox add qccheckbox (drop-down list box insert check box, including source code + comments)
- [tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
- Classes and objects - initialization and cleanup of objects - constructor call rules
- Awk from entry to burial (1) awk first meeting
猜你喜欢
A2L file parsing based on CAN bus (2)
Random Shuffle attention
Practice of traffic recording and playback in vivo
Build a private cloud disk cloudrev
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
Return a tree structure data
Add MDF database file to SQL Server database, and the error is reported
xiaodi-笔记
Awk from introduction to earth (0) overview of awk
《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨
随机推荐
QT qcombobox add qccheckbox (drop-down list box insert check box, including source code + comments)
Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
[hcia]no.15 communication between VLANs
基于can总线的A2L文件解析(2)
GBase 8c系统表-pg_auth_members
Linear rectification function relu and its variants in deep learning activation function
Packing and unpacking of JS
Javescript 0.1 + 0.2 = = 0.3 problem
GBase 8c系统表-pg_amproc
Why choose a frame? What frame to choose
Word word word
4. Classes and objects
HTB-Devel
Gbase 8C system table PG_ collation
HW initial preparation
awk从入门到入土(0)awk概述
基于线程池的生产者消费者模型(含阻塞队列)
Gbase 8C trigger (I)
Mathematical statistics -- Sampling and sampling distribution
Check log4j problems using stain analysis