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

边栏推荐
- Producer consumer model based on thread pool (including blocking queue)
- [hcia]no.15 communication between VLANs
- Tongda OA homepage portal workbench
- Matlab tips (24) RBF, GRNN, PNN neural network
- [tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
- leetcode540
- [principles of multithreading and high concurrency: 1_cpu multi-level cache model]
- 【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
- 【教程】chrome關閉跨域策略cors、samesite,跨域帶上cookie
- Add automatic model generation function to hade
猜你喜欢

HW-初始准备

sql server数据库添加 mdf数据库文件,遇到的报错

Return a tree structure data

Choose it when you decide

A2L file parsing based on CAN bus (2)

Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)

Can netstat still play like this?

Mathematical statistics -- Sampling and sampling distribution
![[translation] the background project has joined the CNCF incubator](/img/0b/e3d2674b1a1cba3ea398cbcb1a018a.png)
[translation] the background project has joined the CNCF incubator

random shuffle注意
随机推荐
Machine learning process and method
【教程】chrome關閉跨域策略cors、samesite,跨域帶上cookie
Gbase 8C system table PG_ collation
GBase 8c系统表-pg_aggregate
Gbase 8C function / stored procedure parameters (I)
GBase 8c 函数/存储过程参数(二)
Build a private cloud disk cloudrev
UDP receive queue and multiple initialization test
Memory pool (understand the process of new developing space from the perspective of kernel)
Practice of traffic recording and playback in vivo
GBase 8c 函数/存储过程定义
【 tutoriel】 Chrome ferme les cors et les messages de la politique inter - domaines et apporte des cookies à travers les domaines
Pytorch convolution network regularization dropblock
[translation] flux is safe. Gain more confidence through fuzzy processing
easyPOI
xiaodi-笔记
Gbase 8C function / stored procedure parameters (II)
疫情当头,作为Leader如何进行代码版本和需求开发管控?| 社区征文
Wechat - developed by wechat official account Net core access
Thread safe singleton mode