DiNAMitiON / SpetsLogging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpetsLogging

SpetsLogging is a simple way to log in the console and in a file.

Installing

Install and update using pip:

$ pip install spetsloging

A Simple Example

main.py

import spetslogging
import time
log = spetslogging.logger.Log()
log.settings(
    Format='%d%.%m%.%y% %h%:%m%:%s% %stat% >> %message%',
    Colors={
        'INFO': 'CYAN',
        'DEBUG': 'YELLOW',
        'WARNING': 'LIGHTRED'
    }
)
for i in range(5):
    log.info(i, file='test.log')
    log.error('Test', shell=False, file='test.log')
    time.sleep(0.5)

log.debug('Program completed')

Output

31.10.2023 12:10:41 [INFO] >> 0
31.10.2023 12:10:41 [ERROR] >> Test
31.10.2023 12:10:42 [INFO] >> 1
31.10.2023 12:10:42 [ERROR] >> Test
31.10.2023 12:10:42 [INFO] >> 2
31.10.2023 12:10:42 [ERROR] >> Test
31.10.2023 12:10:43 [INFO] >> 3
31.10.2023 12:10:43 [ERROR] >> Test
31.10.2023 12:10:43 [INFO] >> 4
31.10.2023 12:10:43 [ERROR] >> Test
31.10.2023 12:10:44 [DEBUG] >> Program completed

test.log

31.10.2023 12:10:41 [INFO] >> 0
31.10.2023 12:10:41 [ERROR] >> Test
31.10.2023 12:10:42 [INFO] >> 1
31.10.2023 12:10:42 [ERROR] >> Test
31.10.2023 12:10:42 [INFO] >> 2
31.10.2023 12:10:42 [ERROR] >> Test
31.10.2023 12:10:43 [INFO] >> 3
31.10.2023 12:10:43 [ERROR] >> Test
31.10.2023 12:10:43 [INFO] >> 4
31.10.2023 12:10:43 [ERROR] >> Test

Donate

To support the development of the library, support its author. https://donationalerts.com/r/dinamition

Links

About


Languages

Language:Python 100.0%