v2.0.1 업데이트
This commit is contained in:
@ -13,6 +13,15 @@ if sys.platform == 'win32':
|
||||
import os
|
||||
os.system('') # ANSI escape sequences 활성화
|
||||
|
||||
# UTF-8 콘솔 출력 설정
|
||||
try:
|
||||
import ctypes
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
kernel32.SetConsoleCP(65001) # UTF-8 input
|
||||
kernel32.SetConsoleOutputCP(65001) # UTF-8 output
|
||||
except:
|
||||
pass
|
||||
|
||||
# ANSI 컬러 코드
|
||||
class Colors:
|
||||
RESET = '\033[0m'
|
||||
@ -113,8 +122,15 @@ class DSLogger:
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
self.logger.handlers.clear() # 기존 핸들러 제거
|
||||
|
||||
# 콘솔 핸들러
|
||||
console_handler = logging.StreamHandler(sys.stdout)
|
||||
# 콘솔 핸들러 (UTF-8 강제)
|
||||
if sys.platform == 'win32':
|
||||
# Windows에서 UTF-8 출력 스트림 사용
|
||||
import io
|
||||
console_stream = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', line_buffering=True)
|
||||
else:
|
||||
console_stream = sys.stdout
|
||||
|
||||
console_handler = logging.StreamHandler(console_stream)
|
||||
console_handler.setLevel(getattr(logging, console_level.upper()))
|
||||
console_handler.setFormatter(ColoredFormatter(colored=colored))
|
||||
self.logger.addHandler(console_handler)
|
||||
|
||||
Reference in New Issue
Block a user