#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: logHelper.py
 @DateTime: 2025/6/21 16:53
 @SoftWare: PyCharm
 @Author  ：xsh
"""
from PyQt5 import Qt
from inspect import getframeinfo, stack
from AppLog.logManager import (logManager, logEvent, logEvent, LogMode, logSlot, logUtils, log_exception,
                               logSingleton, LOG, LogLevel)

app_logger: logManager = logManager.GetInstance()
def UTFString(buffer: object) -> str:
    return f"{buffer}".encode('utf-8')

def qt_message_handler(mode: object, context: Qt.QMessageLogContext, message: object):
    string = f"FILE:[{Qt.QFileInfo(context.file).fileName()}]\tLINE:[{context.line}]\t{message}"
    logSlot.GetInstance().logSendSignal.emit(mode, string)

Qt.qInstallMessageHandler(qt_message_handler)

logOTHER            : LOG = LOG(level=LogLevel.LOG_OTHER       , parent=None)
logDEBUG            : LOG = LOG(level=LogLevel.LOG_DEBUG       , parent=None)
logWARNING          : LOG = LOG(level=LogLevel.LOG_WARNING     , parent=None)
logSYSTEM           : LOG = LOG(level=LogLevel.LOG_SYSTEM      , parent=None)
logFATAL            : LOG = LOG(level=LogLevel.LOG_FATAL       , parent=None)
logINFO             : LOG = LOG(level=LogLevel.LOG_INFO        , parent=None)
logMODBUS           : LOG = LOG(level=LogLevel.LOG_MODBUS      , parent=None)
logSERIAL           : LOG = LOG(level=LogLevel.LOG_SERIAL      , parent=None)
logMANIPULATOR      : LOG = LOG(level=LogLevel.LOG_MANIPULATOR , parent=None)
logMICROSCOPE       : LOG = LOG(level=LogLevel.LOG_MICROSCOPE  , parent=None)
logFLOW             : LOG = LOG(level=LogLevel.LOG_FLOW        , parent=None)
logDB               : LOG = LOG(level=LogLevel.LOG_DB          , parent=None)
logWEBSERVER        : LOG = LOG(level=LogLevel.LOG_WEBSERVER   , parent=None)
logCAMERA           : LOG = LOG(level=LogLevel.LOG_CAMERA      , parent=None)
logHITBOT           : LOG = LOG(level=LogLevel.LOG_HITBOT      , parent=None)
logSOCKET           : LOG = LOG(level=LogLevel.LOG_SOCKET      , parent=None)
logSCANNING         : LOG = LOG(level=LogLevel.LOG_SCANNING    , parent=None)
