19 lines
644 B
Python
19 lines
644 B
Python
|
|
import logging
|
||
|
|
import sys
|
||
|
|
from logging.handlers import RotatingFileHandler
|
||
|
|
|
||
|
|
def setup_logging():
|
||
|
|
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||
|
|
|
||
|
|
|
||
|
|
def setup_rotating_logging(log_path):
|
||
|
|
# Rotación de logs con un tamaño máximo de 5 MB y mantiene 15 archivos de backup
|
||
|
|
handler = RotatingFileHandler(log_path, maxBytes=5*1024*1024, backupCount=15, encoding="utf8")
|
||
|
|
|
||
|
|
# Configuración básica de logging
|
||
|
|
logging.basicConfig(
|
||
|
|
handlers=[handler],
|
||
|
|
level=logging.INFO,
|
||
|
|
format='%(asctime)s - %(levelname)s - %(message)s'
|
||
|
|
)
|