Класс для лога. Подробнее...
#include <utilities/log_stream.h>
Открытые члены | |
LogStream (const char *theLogFilePath=NULL, std::size_t theSyncMode=ASYNC_LOGGING) | |
LogStream (const std::string &theLogFilePath, std::size_t theSyncMode=ASYNC_LOGGING) | |
LogStream & | operator<< (const char *LogString) |
LogStream & | operator<< (const std::string &LogString) |
void | Reset (const char *theLogFilePath=NULL, std::size_t SyncMode=ASYNC_LOGGING) |
ALIAS_FUNCTION_2 (Reset, aliasReset, const char *, std::size_t) | |
void | Reset (const std::string &theLogFilePath=NULL, std::size_t SyncMode=ASYNC_LOGGING) |
void | Release (void) |
~LogStream () | |
Закрытые данные | |
std::string | LogFilePath |
std::size_t | SyncMode |
nitro::FileAbstraction | FileAccessObject |
nitro::MutexAbstraction * | LogMutex |
Класс для лога.
См. определение в файле log_stream.h строка 73
nitro::LogStream::LogStream | ( | const char * | theLogFilePath = NULL , |
|
std::size_t | theSyncMode = ASYNC_LOGGING | |||
) |
Конструктор.
theLogFilePath | - Путь к файлу логов. | |
theSyncMode | - Режим синхронизации. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 10
Перекрестные ссылки nitro::exception::code(), LogFilePath, LogMutex, SyncMode и nitro::exception::what().
{ try { if( theLogFilePath == NULL ) { LogFilePath = "./system.log"; } else { LogFilePath = theLogFilePath; } SyncMode = theSyncMode; LogMutex = NULL; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::LogStream( const char * theLogFilePath /* = NULL */ , std::size_t theSyncMode /* = ASYNC_LOGGING */ )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::LogStream( const char * theLogFilePath /* = NULL */ , std::size_t theSyncMode /* = ASYNC_LOGGING */ )::An error occured" ) , 0 ) ); } }
nitro::LogStream::LogStream | ( | const std::string & | theLogFilePath, | |
std::size_t | theSyncMode = ASYNC_LOGGING | |||
) |
Конструктор.
theLogFilePath | - Путь к файлу логов. | |
theSyncMode | - Режим синхронизации. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 35
Перекрестные ссылки nitro::exception::code(), LogFilePath, LogMutex, SyncMode и nitro::exception::what().
{ try { if( theLogFilePath == "" ) { LogFilePath = "./system.log"; } else { LogFilePath = theLogFilePath; } SyncMode = theSyncMode; LogMutex = NULL; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::LogStream( const std::string & theLogFilePath , std::size_t theSyncMode /* = ASYNC_LOGGING */ )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::LogStream( const std::string & theLogFilePath , std::size_t theSyncMode /* = ASYNC_LOGGING */ )::An error occured" ) , 0 ) ); } }
nitro::LogStream::~LogStream | ( | ) |
Деструктор.
См. определение в файле log_stream.cpp строка 187
Перекрестные ссылки nitro::exception::code(), Release() и nitro::exception::what().
{ try { Release(); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::~LogStream()::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::~LogStream()::An error occured" ) , 0 ) ); } }
nitro::LogStream::ALIAS_FUNCTION_2 | ( | Reset | , | |
aliasReset | , | |||
const char * | , | |||
std::size_t | ||||
) |
LogStream & nitro::LogStream::operator<< | ( | const char * | LogString | ) |
Метод для вывода строки в лог.
LogString | - Выводимая строка. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 60
Перекрестные ссылки nitro::exception::code(), FileAccessObject, nitro::MutexAbstraction::Lock(), LogFilePath, LogMutex, Reset(), SyncMode, nitro::MutexAbstraction::UnLock(), nitro::exception::what() и nitro::FileAbstraction::Write().
{ try { if( SyncMode != 2 ) { Reset( LogFilePath.c_str() , SyncMode ); SyncMode = 2; } if( LogMutex ) { LogMutex->Lock(); } FileAccessObject.Write( LogString , strlen( LogString ) ); if( LogMutex ) { LogMutex->UnLock(); } return( * this ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::operator<<( const char * LogString )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::operator<<( const char * LogString )::An error occured" ) , 0 ) ); } }
LogStream & nitro::LogStream::operator<< | ( | const std::string & | LogString | ) |
Метод для вывода строки в лог.
LogString | - Выводимая строка. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 94
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
{ try { return( ( * this ) << LogString.c_str() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::operator<<( const std::string & LogString )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::operator<<( const std::string & LogString )::An error occured" ) , 0 ) ); } }
void nitro::LogStream::Release | ( | void | ) |
Функция уничтожения объекта.
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 164
Перекрестные ссылки nitro::FileAbstraction::Close(), nitro::exception::code(), FileAccessObject, LogMutex, nitro::MutexAbstraction::Release() и nitro::exception::what().
Используется в Reset() и ~LogStream().
{ try { if( LogMutex ) { LogMutex->Release(); delete LogMutex; LogMutex = NULL; } FileAccessObject.Close(); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::Release( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::Release( void )::An error occured" ) , 0 ) ); } }
void nitro::LogStream::Reset | ( | const char * | theLogFilePath = NULL , |
|
std::size_t | SyncMode = ASYNC_LOGGING | |||
) |
Функция переустановки свойств объекта.
theLogFilePath | - Путь к файлу логов. | |
SyncMode | - Режим синхронизации. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 110
Перекрестные ссылки nitro::exception::code(), nitro::MutexAbstraction::CreateMutex(), nitro::FA_FILE_APPEND, nitro::FA_FILE_BINARY, nitro::FA_FILE_WRITE, FileAccessObject, LogFilePath, LogMutex, nitro::FileAbstraction::Open(), Release(), nitro::SYNC_LOGGING, SyncMode и nitro::exception::what().
Используется в operator<<() и Reset().
{ try { Release(); if( theLogFilePath == NULL ) { LogFilePath = "./system.log"; } else { LogFilePath = theLogFilePath; } SyncMode = theSyncMode; if( SyncMode == nitro::SYNC_LOGGING ) { LogMutex = new nitro::MutexAbstraction(); LogMutex->CreateMutex(); } else { LogMutex = NULL; } FileAccessObject.Open( LogFilePath , nitro::FA_FILE_BINARY | nitro::FA_FILE_WRITE | FA_FILE_APPEND ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::Reset( const char * LogFilePath /* = NULL */ , std::size_t SyncMode /* = ASYNC_LOGGING */ )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::Reset( const char * LogFilePath /* = NULL */ , std::size_t SyncMode /* = ASYNC_LOGGING */ )::An error occured" ) , 0 ) ); } }
void nitro::LogStream::Reset | ( | const std::string & | theLogFilePath = NULL , |
|
std::size_t | SyncMode = ASYNC_LOGGING | |||
) |
Функция переустановки свойств объекта.
theLogFilePath | - Путь к файлу логов. | |
SyncMode | - Режим синхронизации. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле log_stream.cpp строка 148
Перекрестные ссылки nitro::exception::code(), Reset() и nitro::exception::what().
{ try { Reset( theLogFilePath.c_str() , theSyncMode ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "LogStream::Reset( const std::string & theLogFilePath /* = NULL */ , std::size_t theSyncMode /* = ASYNC_LOGGING */ )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "LogStream::Reset( const std::string & theLogFilePath /* = NULL */ , std::size_t theSyncMode /* = ASYNC_LOGGING */ )::An error occured" ) , 0 ) ); } }
Объект для доступа к файлу.
См. определение в файле log_stream.h строка 286
Используется в operator<<(), Release() и Reset().
std::string nitro::LogStream::LogFilePath [private] |
Путь к файлу с логом.
См. определение в файле log_stream.h строка 262
Используется в LogStream(), operator<<() и Reset().
Объект для доступа к файлу.
См. определение в файле log_stream.h строка 298
Используется в LogStream(), operator<<(), Release() и Reset().
std::size_t nitro::LogStream::SyncMode [private] |
Режим синхронизации.
См. определение в файле log_stream.h строка 274
Используется в LogStream(), operator<<() и Reset().