//---------------------------------------------------------------------------- // EgalTech 2025-2025 //---------------------------------------------------------------------------- // File : Logger.cpp Data : 24.01.25 Versione : 2.7a1 // Contenuto : Implementazione funzioni gestione outlog. // // // Modifiche : 24.01.25 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "StringUtils.h" #include "/EgtDev/Include/EBsAPI.h" #include "/EgtDev/Include/EgtLogger.h" #include using namespace std ; using namespace egtlogger ; //---------------------------------------------------------------------------- static int s_nDebugLev = 0 ; static Logger* s_pGenLog = nullptr ; //----------------------------------------------------------------------------- BOOL __stdcall EgtInitLogger( int nDebug, const wchar_t* wsLogFile) { // cancello eventuale vecchio logger if ( s_pGenLog != nullptr) delete s_pGenLog ; // assegno il livello di debug s_nDebugLev = max( nDebug, 0) ; // creo il logger generale s_pGenLog = new( nothrow) Logger( ( s_nDebugLev > 0 ? LL_DEBUG : LL_INFO), "EgtBasis") ; if ( s_pGenLog == nullptr) return FALSE ; // assegno il file s_pGenLog->AddOutputStream( new( nothrow) ofstream( wsLogFile), true) ; return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtOutLog( const wchar_t* wsMsg, int nDebugLevel) { if ( s_pGenLog == nullptr) return FALSE ; if ( nDebugLevel == 0) LOG_INFO( s_pGenLog, wstrztoA( wsMsg)) else if ( s_nDebugLev >= nDebugLevel) LOG_DBG_INFO( s_pGenLog, wstrztoA( wsMsg)) return TRUE ; } //----------------------------------------------------------------------------- ILogger* GetLogger( void) { return s_pGenLog ; }