Metadata-Version: 2.5
Name: cplogger
Version: 0.1.1
Summary: Color Print and logging
Project-URL: Homepage, https://github.com/HonamSong/cplogger
Project-URL: Repository, https://github.com/HonamSong/cplogger
Author-email: Honam Song <louky0714@gmail.com>
License: MIT
License-File: LICENSE
Keywords: color print,logging,print
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Logging
Classifier: Topic :: Utilities
Requires-Python: >=3.7
Requires-Dist: termcolor>=1.1.0
Description-Content-Type: text/markdown

# cplogger

![version](https://img.shields.io/badge/version-0.1.0-blue.svg)
![python](https://img.shields.io/badge/python-3.7%2B-blue.svg)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
![platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey.svg)
![PyPI](https://img.shields.io/pypi/v/cplogger.svg)

색상 print 로그와 파일 로그를 함께 지원하는 경량 Python 로거.

- 로그 레벨별 컬러 콘솔 출력 (info / warn / error / debug)
- 파일 기록 (`write`), 콘솔 출력 (`print`), 동시 사용 (`all`) 모드 지원
- 파일명 / 함수명 / 라인 번호 자동 표시 옵션
- 사용자 정의 색상 및 커스텀 로그 라인 지원

## 설치

PyPI:

```bash
pip install cplogger
```

GitHub 최신본:

```bash
pip install git+https://github.com/HonamSong/cplogger.git
```

## Logging class attribute

```python
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
```

## 사용

### 기본 컬러 로그

```python
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](./img/default_loglevel_color.png)

### 사용자 정의 로그

```python
from cplogger import *

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

![alt custom_logger](./img/custom_logger.png)

### 지원 색상

color|attribute
---|---
![#008000](https://dummyimage.com/20x20/008000/008000.png)|***green*** (default info color)
![#FF00FF](https://dummyimage.com/20x20/FF00FF/FF00FF.png)|magenta (default warn color)
![#ff0000](https://dummyimage.com/20x20/ff0000/ff0000.png)|red (default error color)
![#FFEA00](https://dummyimage.com/20x20/FFEA00/FFEA00.png)|yellow (default debug color)
![#B6D0E2](https://dummyimage.com/20x20/B6D0E2/B6D0E2.png)|blue
![#808080](https://dummyimage.com/20x20/808080/808080.png)|grey
![#00FFFF](https://dummyimage.com/20x20/00FFFF/00FFFF.png)|cyan
![#FFFFFF](https://dummyimage.com/20x20/FFFFFF/FFFFFF.png)|white

### 파일에만 기록 (`log_mode="write"`)

```python
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](./img/write_to_file.png)

### 콘솔 + 파일 동시 기록 (`log_mode="all"`)

```python
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](./img/log_mode_all_default.png)

## License

MIT