mirror of
https://github.com/Zetaphor/browser-recall.git
synced 2025-12-06 02:19:37 +00:00
36 lines
998 B
Python
36 lines
998 B
Python
import logging
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
class Logger:
|
|
_instance: Optional['Logger'] = None
|
|
|
|
def __new__(cls):
|
|
if cls._instance is None:
|
|
cls._instance = super().__new__(cls)
|
|
cls._instance._initialize()
|
|
return cls._instance
|
|
|
|
def _initialize(self):
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(levelname)s - %(message)s',
|
|
handlers=[
|
|
logging.FileHandler(f'logs/main_{datetime.now().strftime("%Y%m%d")}.log'),
|
|
logging.StreamHandler()
|
|
]
|
|
)
|
|
self.logger = logging.getLogger(__name__)
|
|
|
|
def info(self, message: str):
|
|
self.logger.info(message)
|
|
|
|
def error(self, message: str):
|
|
self.logger.error(message)
|
|
|
|
def warning(self, message: str):
|
|
self.logger.warning(message)
|
|
|
|
def debug(self, message: str):
|
|
self.logger.debug(message) |