in Logger.h :
#ifndef CLASS_LOG_H
#define CLASS_LOG_H
#include <exception>
#include <iostream>
#include <fstream>
#include <time.h>
namespace Log
{
    class LoggerMess
    {
        public:
            LoggerMess():fileStr("LOG_MESS") {};
            ~LoggerMess() {};
            template<typename T>
            LoggerMess& operator << ( const T &mess )
            {
                try
                {
                    fileName.exceptions( std::fstream::failbit );
                    fileName.open ( fileStr.c_str(), std::ofstream::app );
                    fileName << mess;
                    fileName.close();
                }
                catch ( std::exception &e )
                {
                    std::cerr << "Exception caught: " << e.what() << std::endl;
                }
                return *this;
            };
            void setLogFile ( const std::string &Fset ) { fileStr = Fset; };
        private:
            std::ofstream fileName;
            std::string fileStr;
    };
    class LoggerCerr
    {
        public:
            LoggerCerr():fileStr("LOG_ERR") {};
            ~LoggerCerr() {};
            template<typename T>
            LoggerCerr& operator << ( const T &mess )
            {
                try
                {
                    fileName.exceptions( std::fstream::failbit );
                    fileName.open ( fileStr.c_str(), std::ofstream::app );
                    fileName << mess;
                    fileName.close();
                }
                catch ( std::exception &e )
                {
                    std::cerr << "Exception caught: " << e.what() << std::endl;
                }
                return *this;
            };
            void setLogFile ( const std::string &Fset ) { fileStr = Fset; };
        private:
            std::ofstream fileName;
            std::string fileStr;
    };
    extern LoggerMess mess;
    extern LoggerCerr cerr;
};
#endif
in  Logger.cpp
#include "Logger.h"
namespace Log
{
    LoggerMess mess;
    LoggerCerr cerr;
};
Используем так :
include "Logger.h"
int main ()
{
   Log::cerr << "error";
   Log::mess << "mess";
}
Скажите пожалуйста, где здесь ошибка? 
И что можно было бы исправить?
Спасибо

    
      Ответ на:
      
          комментарий
        от fghj 
  
    
      Ответ на:
      
          комментарий
        от aton 
  
    
      Ответ на:
      
          комментарий
        от hbee 
  
    
      Ответ на:
      
          комментарий
        от aton 
  
    
      Ответ на:
      
          комментарий
        от tarle 
  
    
      Ответ на:
      
          комментарий
        от fura13 
  
    
      Ответ на:
      
          комментарий
        от hbee 
  
    
      Ответ на:
      
          комментарий
        от aton 
  
    
      Ответ на:
      
          комментарий
        от hbee 
  
    
      Ответ на:
      
          комментарий
        от aton 
  
    
      Ответ на:
      
          комментарий
        от anonymous 
  
    
      Ответ на:
      
          комментарий
        от tarle 
  
    
        Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
      
Похожие темы
- Форум C++ iostream::failbit (2005)
 - Форум boost.asio, boost.serialization (2010)
 - Форум Валится на throw (2005)
 - Форум Продолжим про исключения!! (2007)
 - Форум Шаблоны, почему не работает? (2017)
 
- Форум [C++, boost::spirit::phoenix, std::get] Обернуть std::get в phoenix-овскую function (2011)
 - Форум Багофича эксепшенов с++ ? (2013)
 - Форум C++ IOstream Library и вывод сообщений об ошибках (2009)
 - Форум Как правильно наследовать от std::exception ? (2007)
 - Форум Множественное наследование и try/catch inderect base, C++ (2008)