当前位置:网站首页>超好用的日志库 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)
边栏推荐
- [tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
- Gbase 8C trigger (III)
- Monitoring and management of JVM
- 为什么会选择框架?选择什么样的框架
- sql server数据库添加 mdf数据库文件,遇到的报错
- UDP receive queue and multiple initialization test
- random shuffle注意
- Create + register sub apps_ Define routes, global routes and sub routes
- 错误Invalid bound statement (not found): com.ruoyi.stock.mapper.StockDetailMapper.xxxx解决
- The sandbox explains its vision for the meta universe platform
猜你喜欢
Build a private cloud disk cloudrev
Xiaodi notes
【翻译】具有集中控制平面的现代应用负载平衡
HW-初始准备
[translation] modern application load balancing with centralized control plane
Tongda OA homepage portal workbench
What does "where 1=1" mean
Thread safe singleton mode
Tongda OA V12 process center
The Linux server needs to install the agent software EPS (agent) database
随机推荐
【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
Strategy application of Dameng database
Gbase 8C system table PG_ cast
【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)
Apple releases MacOS 11.6.4 update: mainly security fixes
[Hcia]No.15 Vlan间通信
cvpr2022去雨去雾
Classes and objects - initialization and cleanup of objects - constructor call rules
【教程】chrome关闭跨域策略cors、samesite,跨域带上cookie
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
GBase 8c系统表-pg_collation
A2L file parsing based on CAN bus (2)
定了,就选它
GBase 8c系统表pg_database
Random Shuffle attention
[fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
COM and cn
sql server 查询指定表的表结构
线程安全的单例模式
怎么将yolov5中的PANet层改为BiFPN