5 changed files with 81 additions and 134 deletions
-
7src/cli/cli.cpp
-
43src/utility/initialize.cpp
-
7src/utility/initialize.h
-
23src/utility/logging.h
-
135src/utility/macros.h
@ -1,30 +1,55 @@ |
|||||
#include "initialize.h"
|
#include "initialize.h"
|
||||
|
|
||||
#include "src/utility/macros.h"
|
|
||||
#include "src/settings/SettingsManager.h"
|
#include "src/settings/SettingsManager.h"
|
||||
#include "src/settings/modules/DebugSettings.h"
|
#include "src/settings/modules/DebugSettings.h"
|
||||
|
|
||||
int storm_runtime_loglevel = STORM_LOGLEVEL_WARN; |
#include <iostream>
|
||||
|
#include <fstream>
|
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
namespace utility { |
namespace utility { |
||||
|
|
||||
void initializeLogger() { |
void initializeLogger() { |
||||
// Intentionally left empty.
|
l3pp::Logger::initialize(); |
||||
|
// By default output to std::cout
|
||||
|
l3pp::SinkPtr sink = l3pp::StreamSink::create(std::cout); |
||||
|
l3pp::Logger::getRootLogger()->addSink(sink); |
||||
|
// Default to warn, set by user to something else
|
||||
|
l3pp::Logger::getRootLogger()->setLevel(l3pp::LogLevel::WARN); |
||||
|
|
||||
|
l3pp::FormatterPtr fptr = l3pp::makeTemplateFormatter( |
||||
|
l3pp::FieldStr<l3pp::Field::LogLevel, 5, l3pp::Justification::LEFT>(), |
||||
|
' (', l3pp::FieldStr<l3pp::Field::FileName>, ':', l3pp::FieldStr<l3pp::Field::Line>, '): ', |
||||
|
l3pp::FieldStr<l3pp::Field::Message>(), '\n' |
||||
|
); |
||||
|
sink->setFormatter(fptr); |
||||
} |
} |
||||
|
|
||||
void setUp() { |
void setUp() { |
||||
initializeLogger(); |
initializeLogger(); |
||||
std::cout.precision(10); |
std::cout.precision(10); |
||||
} |
} |
||||
|
|
||||
void cleanUp() { |
void cleanUp() { |
||||
// Intentionally left empty.
|
// Intentionally left empty.
|
||||
} |
} |
||||
|
void setLogLevel(l3pp::LogLevel level) { |
||||
|
l3pp::Logger::getRootLogger()->setLevel(level); |
||||
|
if (level <= l3pp::LogLevel::DEBUG) { |
||||
|
#if STORM_LOG_DISABLE_DEBUG
|
||||
|
std::cout << "***** warning ***** requested loglevel is not compiled\n"; |
||||
|
#endif
|
||||
|
} |
||||
|
} |
||||
|
|
||||
void initializeFileLogging() { |
void initializeFileLogging() { |
||||
// FIXME.
|
if (storm::settings::getModule<storm::settings::modules::DebugSettings>().isLogfileSet()) { |
||||
|
std::string logFileName = storm::settings::getModule<storm::settings::modules::DebugSettings>().getLogfilename(); |
||||
|
l3pp::SinkPtr sink = l3pp::FileSink::create(logFileName); |
||||
|
l3pp::Logger::getRootLogger()->addSink(sink); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
} |
} |
||||
} |
} |
@ -0,0 +1,23 @@ |
|||||
|
#ifndef STORM_UTILITY_LOGGING_H_ |
||||
|
#define STORM_UTILITY_LOGGING_H_ |
||||
|
|
||||
|
#include <l3pp/logging.h> |
||||
|
|
||||
|
#if !defined(STORM_LOG_DISABLE_DEBUG) && !defined(STORM_LOG_DISABLE_TRACE) |
||||
|
#define STORM_LOG_TRACE(message) L3PP_LOG_TRACE(l3pp::Logging::getRootLogger(), message) |
||||
|
#else |
||||
|
#define STORM_LOG_TRACE(message) (void)(0) |
||||
|
#endif |
||||
|
|
||||
|
#if !defined(STORM_LOG_DISABLE_DEBUG) |
||||
|
#define STORM_LOG_DEBUG(message) L3PP_LOG_DEBUG(l3pp::Logging::getRootLogger(), message) |
||||
|
#else |
||||
|
#define STORM_LOG_DEBUG(message) (void)(0) |
||||
|
#endif |
||||
|
|
||||
|
// Define STORM_LOG_WARN, STORM_LOG_ERROR and STORM_LOG_INFO to log the given message with the corresponding log levels. |
||||
|
#define STORM_LOG_INFO(message) L3PP_LOG_INFO(l3pp::Logging::getRootLogger(), message) |
||||
|
#define STORM_LOG_WARN(message) L3PP_LOG_WARN(l3pp::Logging::getRootLogger(), message) |
||||
|
#define STORM_LOG_ERROR(message) L3PP_LOG_ERROR(l3pp::Logging::getRootLogger(), message) |
||||
|
|
||||
|
#endif /* STORM_UTILITY_LOGGING_H_ */ |
Reference in new issue
xxxxxxxxxx