Skip to main content

ilogger

超简单的日志模块,导入即用

如何使用它?

>>> pip install ilogger

简单使用,默认级别为 INFO

from ilogger import logger

logger.debug('this is debug message')
logger.info('this is info message')
[2019-09-24 19:54:23,544]   INFO: this is info message

设置 logger 级别

from ilogger import logger

logger.setLevel(logger.DEBUG)

logger.debug('this is debug message')
logger.info('this is info message')
logger.warning('this is warning message')
logger.warn('this is warning message')
logger.error('this is error message')
logger.critical('this is critical message')
[2019-09-24 19:54:23,544]  DEBUG: this is debug message
[2019-09-24 19:54:23,544]   INFO: this is info message
[2019-09-24 19:54:23,544]WARNING: this is warning message
[2019-09-24 19:54:23,544]WARNING: this is warning message
[2019-09-24 19:54:23,544]  ERROR: this is error message
[2019-09-24 19:54:23,544]CRITICAL: this is critical message

设置 logger 格式

from ilogger import logger

logger.setFormatter(fmt='[%(asctime)s]%(levelname)7s[%(filename)s:%(lineno)s]: %(message)s')

logger.debug('this is debug message')
logger.info('this is info message')
[2019-09-24 19:54:23,544]  DEBUG[demo.py:21]: this is debug message
[2019-09-24 19:54:23,544]   INFO[demo.py:22]: this is info message

将日志写入到文件

from ilogger import logger

# 设置 logger 格式
logger.setFormatter(fmt='[%(asctime)s]%(levelname)7s[%(filename)s:%(lineno)s]: %(message)s')
logger.setFileHandler('mylog.log')

logger.debug('this is debug message')
logger.info('this is info message')
logger.warning('this is warning message')

./mylog.log

[2020-02-28 20:57:17,199]   INFO[demo.py:35]: this is info message
[2020-02-28 20:57:17,199]WARNING[demo.py:36]: this is warning message

Metadata

Release files for ilogger 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ilogger 0.0.3
File Size Uploaded Provenance Actions
ilogger-0.0.3.tar.gz 2.5 kB Without provenance Details for ilogger-0.0.3.tar.gz

Release files / ilogger-0.0.3.tar.gz

Download URL ilogger-0.0.3.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
567e02bc1246e00f62a601b1c2976b312bae07d0903beb8bbc1c3239a8b5faba
BLAKE2b-256 checksum
How to use checksums
1e6f859783f45da1f54f404c4d8b3e9227570704e07d6d877f5e31df98081e37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Security for ilogger 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page