Go to the documentation of this file.00001 #ifndef __LOG_STREAM_H__
00002 #define __LOG_STREAM_H__
00003
00004 #include <system/file_abstraction.h>
00005 #include <system/mutex_abstraction.h>
00006
00007 #if !defined( WIN32_PLATFORM ) && !defined( NIX_PLATFORM ) && !defined( MINGW_PLATFORM ) && !defined( CYGWIN_PLATFORM )
00008 #define WIN32_PLATFORM
00009 #endif
00010
00011 #ifdef LOG_STREAM
00012 #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM ) || defined( CYGWIN_PLATFORM )
00013 #define LOG_STREAM_DLL_ENTITY __declspec( dllexport )
00014 #endif
00015
00016 #if defined( NIX_PLATFORM )
00017 #define LOG_STREAM_DLL_ENTITY
00018 #endif
00019 #else
00020 #ifdef WIN32_PLATFORM
00021 #define LOG_STREAM_DLL_ENTITY __declspec( dllimport )
00022 #pragma comment( lib , "log_stream.lib" )
00023 #endif
00024
00025 #if defined( CYGWIN_PLATFORM ) || defined( MINGW_PLATFORM )
00026 #define LOG_STREAM_DLL_ENTITY __declspec( dllimport )
00027 #endif
00028
00029 #if defined( NIX_PLATFORM )
00030 #define LOG_STREAM_DLL_ENTITY
00031 #endif
00032 #endif
00033
00034 namespace nitro
00035 {
00036
00047 static const std::size_t ASYNC_LOGGING = 0;
00048
00059 static const std::size_t SYNC_LOGGING = 1;
00060
00073 class LOG_STREAM_DLL_ENTITY LogStream{
00074 public:
00075
00098 LogStream( const char * theLogFilePath = NULL , std::size_t theSyncMode = ASYNC_LOGGING );
00099
00122 LogStream( const std::string & theLogFilePath , std::size_t theSyncMode = ASYNC_LOGGING );
00123
00146 LogStream & operator<<( const char * LogString );
00147
00170 LogStream & operator<<( const std::string & LogString );
00171
00194 void Reset( const char * theLogFilePath = NULL , std::size_t SyncMode = ASYNC_LOGGING );
00195
00196 ALIAS_FUNCTION_2( Reset , aliasReset , const char * , std::size_t );
00197
00220 void Reset( const std::string & theLogFilePath = NULL , std::size_t SyncMode = ASYNC_LOGGING );
00221
00236 void Release( void );
00237
00248 ~LogStream();
00249
00250 private:
00251
00262 std::string LogFilePath;
00263
00274 std::size_t SyncMode;
00275
00286 nitro::FileAbstraction FileAccessObject;
00287
00298 nitro::MutexAbstraction * LogMutex;
00299 };
00300
00301 static LogStream stdlog( "./system.log" , SYNC_LOGGING );
00302 static LogStream errorlog( "./error.log" , ASYNC_LOGGING );
00303 };
00304
00305 #endif