Commit db33ac41 authored by Kasper Marstal's avatar Kasper Marstal
Browse files

WIP: Logger tests

parent 57394347
......@@ -58,7 +58,7 @@ macro( _selxmodules_initialize )
option( USE_${MODULE} OFF )
set( ${MODULE}_IS_ENABLED FALSE )
set( ${MODULE}_CMAKE_FILE ${CMAKE_SOURCE_DIR}/${MODULE_CMAKE_FILE} )
set( ${MODULE}_CMAKE_FILE ${CMAKE_SOURCE_DIR}/${${MODULE}_PATH}/${MODULE}.cmake )
set( ${MODULE}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${${MODULE}_PATH} )
set( ${MODULE}_BINARY_DIR ${CMAKE_BINARY_DIR}/${${MODULE}_PATH} )
......@@ -87,7 +87,7 @@ macro( _selxmodule_enable MODULE UPSTREAM )
if( NOT ${MODULE}_IS_ENABLED )
set( ${MODULE}_IS_ENABLED TRUE )
include( ${${MODULE}_CMAKE_FILE} )
if( ${MODULE}_MODULE_DEPENDENCIES )
_selxmodule_enable_dependencies( ${MODULE} ${MODULE}_MODULE_DEPENDENCIES )
endif()
......@@ -115,7 +115,7 @@ macro( _selxmodule_enable MODULE UPSTREAM )
endif()
endif()
add_library( ${MODULE} "${${MODULE}_HEADER_FILES}" "${${MODULE}_SOURCE_FILES}" )
add_library( ${MODULE} ${${MODULE}_HEADER_FILES} ${${MODULE}_SOURCE_FILES} )
endif()
message( STATUS "${MODULE} enabled." )
......
......@@ -17,6 +17,9 @@
#
#=========================================================================
# TODO: This variable is overwritten by the Logger
set( MODULE ModuleFilter )
set( ${MODULE}_INCLUDE_DIRS
${${MODULE}_SOURCE_DIR}/include
)
......@@ -45,4 +48,5 @@ set( ${MODULE}_MODULE_DEPENDENCIES
ModuleItkSmoothingRecursiveGaussianImageFilter
ModuleSinksAndSources
ModuleNiftyreg
ModuleLogger
)
......@@ -37,6 +37,3 @@ set( ${MODULE}_LIBRARIES
${Boost_LIBRARIES} # log filesystem system time_date thread
${MODULE}
)
set( ${MODULE}_MODULE_DEPENDENCIES
)
......@@ -50,10 +50,14 @@ public:
~Logger();
void AddConsole( FormatType format = "[%TimeStamp% %ComponentName% %Channel% %SeverityLevel%]: %Message%" );
void AddFile( FileNameType fileName = "SuperElastix_%Y-%m-%d_%H-%M-%S.%N.log",
RotationSizeType rotationSize = 1024 * 1024 * 1024,
void AddFile( FileNameType fileName = "SuperElastix_%Y-%m-%d_%H-%M-%S.%N.log",
FormatType format = "[%LineID% %TimeStamp% %ComponentName% %Channel% %SeverityLevel%]: %Message%" );
// void AddFile( FileNameType fileName = "SuperElastix_%Y-%m-%d_%H-%M-%S.%N.log",
// Logger::ChannelType channel = "SuperElastix",
// FormatType format = "[%LineID% %TimeStamp% %ComponentName% %Channel% %SeverityLevel%]: %Message%" );
void Log( SeverityType severity, MessageType message );
void Log( ChannelType channel, SeverityType severity, MessageType message );
......
......@@ -37,10 +37,17 @@ Logger
void
Logger
:: AddFile( FileNameType fileName, RotationSizeType rotationSize, FormatType format )
:: AddFile( FileNameType fileName, FormatType format )
{
this->m_Pimple->AddFile( fileName, rotationSize, format );
this->m_Pimple->AddFile( fileName, format );
}
// void
// Logger
// :: AddFile( FileNameType fileName, Logger::ChannelType channel, FormatType format )
// {
// this->m_Pimple->AddFile( fileName, channel, format );
// }
void
Logger
......
......@@ -56,26 +56,24 @@ Logger::LoggerImpl
void
Logger::LoggerImpl
::AddFile( FileNameType fileName, RotationSizeType rotationSize, FormatType format )
::AddFile( FileNameType fileName, FormatType format )
{
boost::log::add_file_log(
boost::log::keywords::file_name = fileName,
boost::log::keywords::rotation_size = rotationSize, // 1GB
boost::log::keywords::format = format
);
}
void
Logger::LoggerImpl
::AddFile( FileNameType fileName, ChannelType channel, RotationSizeType rotationSize, FormatType format )
{
boost::log::add_file_log(
boost::log::keywords::file_name = fileName,
//boost::log::keywords::filter = channel_filter == channel,
boost::log::keywords::rotation_size = rotationSize, // 1GB
boost::log::keywords::format = format
);
}
// void
// Logger::LoggerImpl
// ::AddFile( FileNameType fileName, ChannelType channel, FormatType format )
// {
// boost::log::add_file_log(
// boost::log::keywords::file_name = fileName,
// boost::log::keywords::filter = channel_filter == channel,
// boost::log::keywords::format = format
// );
// }
void
Logger::LoggerImpl
......@@ -89,6 +87,10 @@ Logger::LoggerImpl
strm.flush();
this->m_Logger.push_record( boost::move( record ) );
}
else
{
assert( false );
}
}
void
......@@ -103,6 +105,10 @@ Logger::LoggerImpl
strm.flush();
this->m_Logger.push_record( boost::move( record ) );
}
else
{
assert( false );
}
}
}
......
......@@ -37,8 +37,10 @@ public:
~LoggerImpl();
void AddConsole( FormatType format );
void AddFile( Logger::FileNameType fileName, Logger::ChannelType channel, Logger::RotationSizeType rotationSize, Logger::FormatType format );
void AddFile( Logger::FileNameType fileName, Logger::RotationSizeType rotationSize, Logger::FormatType format );
void AddFile( Logger::FileNameType fileName, Logger::FormatType format );
// void AddFile( Logger::FileNameType fileName, Logger::ChannelType channel, ðLogger::FormatType format );
void Log( SeverityType severity, Logger::MessageType message );
void Log( Logger::ChannelType channel, SeverityType severity, Logger::MessageType message );
......
......@@ -26,4 +26,33 @@ using namespace selx;
TEST( LoggerTest, Initialization )
{
Logger* logger = new Logger();
}
\ No newline at end of file
}
TEST( LoggerTest, Console )
{
Logger* logger = new Logger();
logger->AddConsole();
logger->Log( INFO, "Console INFO message");
}
TEST( LoggerTest, File )
{
Logger* logger = new Logger();
logger->AddFile( "/Users/kasper/Development/build/SuperElastix.txt" );
logger->Log( INFO, "test.log INFO message");
}
TEST( LoggerTest, DefaultChannelFile )
{
Logger* logger = new Logger();
logger->AddFile( "/Users/kasper/Development/build/SuperElastix.txt" );
logger->Log( "SuperElastix", INFO, "test.log INFO message");
}
TEST( LoggerTest, ChannelFile )
{
Logger* logger = new Logger();
logger->AddFile( "/Users/kasper/Development/build/SuperElastix.txt", "OtherChannel" );
logger->Log( "OtherChannel", INFO, "test.log INFO message");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment