cplogger
색상 print 로그와 파일 로그를 함께 지원하는 경량 Python 로거.
- 로그 레벨별 컬러 콘솔 출력 (info / warn / error / debug)
- 파일 기록 (
write), 콘솔 출력 (print), 동시 사용 (all) 모드 지원 - 파일명 / 함수명 / 라인 번호 자동 표시 옵션
- 사용자 정의 색상 및 커스텀 로그 라인 지원
설치
PyPI:
pip install cplogger
GitHub 최신본:
pip install git+https://github.com/HonamSong/cplogger.git
Logging class attribute
class Logging:
def __init__(self, log_path=None, log_file=None,
log_color='green', log_level='INFO', log_mode='print',
log_time_format=None, view_log=True,
view_line_num=False, view_file_name=False, view_func_name=False):
:param log_path: logging path name (default: ./logs)
:param log_file: logging file name (default: ./script_name_yyyymmdd.log)
:param log_color: print log color (default: green)
:param log_level: Default logging level (default: INFO)
:param log_mode: print or loging mode (default: print) [all|write|print]
:param log_time_format: logging Time format (default YYYY-MM-DD HH:MM:SS:3F)
:param view_view: view log by default True (Do Not print boolean is False)
:param view_line_num: view log in line number
:param view_func_name: view log in function name + line number
:param view_file_name: view log in file name + line number
사용
기본 컬러 로그
from cplogger import *
logging = Logging()
# is_view can be skipped
logging.info("info_text", is_view=True)
logging.warn("warn_text", is_view=True)
logging.error("error_text", is_view=True)
logging.debug("debug_text", is_view=True)
사용자 정의 로그
from cplogger import *
logging = Logging()
logging.custom("custom logger", "yellow", "warn", is_view=True, log_file='LOG_FILENAME')
지원 색상
| color | attribute |
|---|---|
| green (default info color) | |
| magenta (default warn color) | |
| red (default error color) | |
| yellow (default debug color) | |
| blue | |
| grey | |
| cyan | |
| white |
파일에만 기록 (log_mode="write")
from cplogger import *
logging = Logging(log_mode="write")
# When log_mode is write, it is not output even if is_view is True.
logging.info('info_logging to file', is_view=True)
logging.warn('warn_logging to file', is_view=True)
logging.error('error_logging to file', is_view=True)
logging.debug('debug_logging to file', is_view=True)
콘솔 + 파일 동시 기록 (log_mode="all")
from cplogger import *
logging = Logging(log_mode="all")
logging.info('info_logging print and write file', is_view=True)
logging.warn('warn_logging print and write file', is_view=True)
logging.error('error_logging print and write file', is_view=True)
logging.debug('debug_logging print and write file', is_view=True)
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cplogger-0.1.0.tar.gz
(5.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cplogger-0.1.0.tar.gz.
File metadata
- Download URL: cplogger-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7cdd7c185eb52ca412412b8d8c848d48a2e0c74428974f02026628679e26aa5
|
|
| MD5 |
2b9f1a631175b7e28b3fb5dd630cc2bd
|
|
| BLAKE2b-256 |
cb39df1fa5224d6274f9e78be1cd88ddde5c3a0ccce2a045c2f0737f95d92d2d
|
File details
Details for the file cplogger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cplogger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e58a6cad6a2638c27f404b05b4a8dcf9778ef130d95b7f50c8ddcf046e684dd4
|
|
| MD5 |
df357418c20adfd15cbac93b96aa36a0
|
|
| BLAKE2b-256 |
0245541111a46e6b7ecdfc48f90843cc2174323d2aae9330d9164cac8e316561
|