2012-03-12 4 views
2

私はcppプロジェクト、cpp cliプロジェクト、およびc#winフォームプロジェクトを持っています。 私はcppネイティブプロジェクトでpantheiosログライブラリを使用しています。
Cpp Pantheiosログライブラリ、デバッグアサーションに失敗したエラー

Log.cpp Log.hpp

#ifndef INCLUDE_LOG_HPP 
#define INCLUDE_LOG_HPP 


#define PANTHEIOS_NO_INCLUDE_OS_AND_3PTYLIB_STRING_ACCESS // Faster compilation 

/* Pantheios Header Files */ 
#include <pantheios/pantheios.hpp>   // Pantheios C++ main header 
#include <pantheios/inserters/args.hpp>  // for pantheios::args 

#include <pantheios/backends/bec.file.h>  // be.file header 

#include "Include/utility.hpp" 
/* Standard C/C++ Header Files */ 
#include <exception>       // for std::exception 
#include <new>        // for std::bad_alloc 
#include <string>        // for std::string 
#include <stdlib.h>   
#include <sstream> 

#define PSTR(x)   PANTHEIOS_LITERAL_STRING(x) 


namespace Mtx 
{ 
    namespace log 
    { 
     class MTXMANAGER Logger 
     { 
     public: 
      void WriteLogIn(const std::string & log_text); 
      Logger(); 
      ~Logger(); 
     }; 
    } 
} 
#endif 


ここ

Log Error

は私のコードです:私は、ログの書き込みをしようとすると、私はこのエラーを取ります

#include "Log.hpp" 
namespace Mtx 
{ 
    namespace log 
    { 
     PANTHEIOS_EXTERN_C const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("mtx");// 
     Logger::Logger() 
     { 
      char path[MAX_PATH]; 
      GetModuleFileName(NULL, path, MAX_PATH); 

      std::string::size_type pos = std::string(path).find_last_of("\\"); 
      strcpy(path,std::string(path).substr(0, pos).c_str()); 
      std::strcat (path,"\\mtx-%D__.log"); 
      ///// 

      pantheios_be_file_setFilePath(PSTR(path), PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BE_FILE_F_SHARE_ON_WINDOWS, PANTHEIOS_BEID_ALL); 

     } 

     Logger::~Logger() 
     { 

     } 

     void Logger::WriteLogIn(const std::string & log_text) 
     { 
      pantheios::log_INFORMATIONAL(PSTR(" [1] "),PSTR(log_text)); 
     } 

    } 
} 

私は、この行でエラーを取る:

pantheios::log_INFORMATIONAL(PSTR(" [1] "),PSTR(log_text)); 

は、どのように私はこのエラーを修正することができますか?

答えて

1

私はあなたに直接答えはありませんが、自分の解決策(これはセットアップと多くの点で似ています - .NET DLLがC++ネイティブDLLを呼び出すのと似ていますが、Pantheios - CLogApp)

  • CLogAppのCTOR/
    • 私はCWinApp派生クラスのためのプロジェクトのInitInstance()とExitInstance()を持っているLOG、(およびctorsを持っている:-logging)、ここで私が持っているものですdtorが空です。
    • InitInstance()とExitInstance()のコード:

      BOOL CLogApp::InitInstance() 
      { 
          CWinApp::InitInstance(); 
      
          int panres = pantheios::pantheios_init(); 
      
          if(panres < 0) 
          { 
           OutputDebugStringA("Could not initialise the Pantheios logging libraries!\n"); 
           util::onBailOut(pantheios::emergency, "Failed to initialise the Pantheios libraries", PANTHEIOS_FE_PROCESS_IDENTITY, /*pantheios::*/pantheios_getInitCodeString(panres)); 
      
           return FALSE; 
          } 
          else 
          { 
          pantheios_be_file_setFilePath(CErrorHandler::getLogPath().c_str(), PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BEID_LOCAL); 
      
          PANTHEIOS_TRACE_NOTICE("STARTING LOGGING"); 
          } 
      
          return TRUE; 
      } 
      
      int CLogApp::ExitInstance() 
      { 
          PANTHEIOS_TRACE_NOTICE("STOPPING LOGGING"); 
          pantheios_uninit(); 
          return 0; 
      } 
      

    これが役立つかどうかはわかりませんが、このコードは長年私のために働いています。

  • 関連する問題