当前位置:网站首页>超好用的日志库 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)

边栏推荐
- Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
- sql server 查詢指定錶的錶結構
- Gbase 8C system table PG_ auth_ members
- sql server数据库添加 mdf数据库文件,遇到的报错
- Tongda OA homepage portal workbench
- Basic operation of binary tree (C language version)
- 5. File operation
- Apple releases MacOS 11.6.4 update: mainly security fixes
- oauth2.0鉴权,登录访问 “/oauth/token”,请求头Authorization(basicToken)如何取值???
- Pytorch convolution network regularization dropblock
猜你喜欢

Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution

awk从入门到入土(0)awk概述

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

【翻译】后台项目加入了CNCF孵化器

内存池(内核角度理解new开辟空间的过程)
![[principles of multithreading and high concurrency: 1_cpu multi-level cache model]](/img/7e/ad9ea78868126b149bd9f15f587e6c.jpg)
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]

《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨

xiaodi-笔记
![[shutter] banner carousel component (shutter_wiper plug-in | swiper component)](/img/a6/5c97ef3f34702b83ebf0511501d757.gif)
[shutter] banner carousel component (shutter_wiper plug-in | swiper component)

HTB-Devel
随机推荐
Practice of traffic recording and playback in vivo
QT qcombobox add qccheckbox (drop-down list box insert check box, including source code + comments)
怎么将yolov5中的PANet层改为BiFPN
GBase 8c系统表-pg_class
GBase 8c触发器(三)
[shutter] banner carousel component (shutter_wiper plug-in | swiper component)
Tongda OA homepage portal workbench
GBase 8c系统表-pg_am
[tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
GBase 8c系统表-pg_aggregate
GBase 8c系统表-pg_amproc
GBase 8c系统表-pg_attribute
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]
Add automatic model generation function to hade
"Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b
Interview stereotyped version
Xiaodi notes
Gbase 8C trigger (II)
cvpr2022去雨去雾
Mathematical statistics -- Sampling and sampling distribution