Skip to main content

cplogger

version python License: MIT platform PyPI

색상 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)

alt levelcolor

사용자 정의 로그

from cplogger import *

logging = Logging()
logging.custom("custom logger", "yellow", "warn", is_view=True, log_file='LOG_FILENAME')

alt custom_logger

지원 색상

color attribute
#008000 green (default info color)
#FF00FF magenta (default warn color)
#ff0000 red (default error color)
#FFEA00 yellow (default debug color)
#B6D0E2 blue
#808080 grey
#00FFFF cyan
#FFFFFF 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)

alt only_write

콘솔 + 파일 동시 기록 (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)

alt log_mode_all

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.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cplogger-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file cplogger-0.1.1.tar.gz.

File metadata

  • Download URL: cplogger-0.1.1.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

Hashes for cplogger-0.1.1.tar.gz
Algorithm Hash digest
SHA256 33617cf87abe6b0e9b36cc57998b3cc9d9859d06dd8b9d52a64e883f93726668
MD5 60b2e21c5358f1bb20dc6e5c494c6e5a
BLAKE2b-256 6b1aee31af6c71dd47ecddbb9d1e2e563a6e3c8653a0a035cb8a1c07c6a8d943

See more details on using hashes here.

File details

Details for the file cplogger-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cplogger-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.8

File hashes

Hashes for cplogger-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54ca3bd36b905bfabe93b5ef139b724409256103f8bcc98ac1693666b9501cf0
MD5 c4eed9ea91060909d48692b911df671d
BLAKE2b-256 4435ee6812eee4b5c4d3371a0f58f0c6f546bca5ab582ca964c5c7c52b61b74b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

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