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

边栏推荐
- 【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)
- Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
- SQL server queries the table structure of the specified table
- HW initial preparation
- awk从入门到入土(3)awk内置函数printf和print实现格式化打印
- require. context
- The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
- Create + register sub apps_ Define routes, global routes and sub routes
- Summary of interview project technology stack
- easyExcel
猜你喜欢

Random shuffle note

Pytest (6) -fixture (Firmware)

定了,就选它

搭建私有云盘 cloudreve

Mathematical statistics -- Sampling and sampling distribution
【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)

Principle and application of database

Producer consumer model based on thread pool (including blocking queue)

random shuffle注意
![[hcia]no.15 communication between VLANs](/img/59/a467c5920cbccb72040f39f719d701.jpg)
[hcia]no.15 communication between VLANs
随机推荐
easyPOI
Principle and application of database
Tongda OA V12 process center
SQL statement
GBase 8c系统表-pg_collation
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
[tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
内存池(内核角度理解new开辟空间的过程)
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
GBase 8c系统表-pg_constraint
Current situation and future of Web3 in various countries
Gbase 8C system table PG_ amop
Build a private cloud disk cloudrev
二维格式数组格式索引下标连续问题导致 返回json 格式问题
Add MDF database file to SQL Server database, and the error is reported
Kubernetes cluster log and efk architecture log scheme
GBase 8c系统表-pg_amproc
sql server数据库添加 mdf数据库文件,遇到的报错
Gbase 8C system table PG_ constraint
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]