32 #ifndef _OMS_LOGGING_H_ 33 #define _OMS_LOGGING_H_ 41 #ifndef __FUNCTION_NAME__ 42 #ifdef WIN32 //WINDOWS 43 #define __FUNCTION_NAME__ __FUNCTION__ 45 #define __FUNCTION_NAME__ __func__ 52 static void Info(
const std::string& msg);
55 static void Debug(
const std::string& msg);
56 static void Trace(
const std::string&
function,
const std::string& file,
const long line);
58 static void ProgressBar(
double start,
double stop,
double value);
76 void printStringToStream(std::ostream& stream,
const std::string& type,
const std::string& msg);
91 unsigned long limit = 1024*1024*50;
100 #define logInfo(msg) Log::Info(msg) 101 #define logWarning(msg) Log::Warning(msg) 102 #define logError(msg) Log::Error(msg, __func__) 106 #define logDebugEnabled() Log::DebugEnabled() 107 #define logTraceEnabled() Log::TraceEnabled() 109 #define logDebug(msg) Log::Debug(msg) 110 #define logTrace() Log::Trace(__FUNCTION_NAME__, __FILE__, __LINE__) 112 #define logDebugEnabled() (0) 113 #define logTraceEnabled() (0) 115 #define logDebug(msg) ((void)0) 116 #define logTrace() ((void)0) 120 #define logError_AlreadyInScope(cref) logError("\"" + std::string(cref) + "\" already exists in the scope") 121 #define logError_AlreadyInScope(cref) logError("\"" + std::string(cref) + "\" already exists in the scope") 122 #define logError_BusAndConnectorNotSameModel(bus, connector) logError("Bus \"" + std::string(bus) + "\" and connector \"" + std::string(connector) + "\" do not belong to same model") 123 #define logError_BusAndConnectorNotSameSystem(bus, connector) logError("Bus \"" + std::string(bus) + "\" and connector \"" + std::string(connector) + "\" do not belong to same system") 124 #define logError_BusNotInComponent(cref, component) logError("Bus connector \"" + std::string(cref) + "\" not found in component \"" + std::string(component->getFullCref()) + "\"") 125 #define logError_BusNotInSystem(cref, system) logError("Bus connector \"" + std::string(cref) + "\" not found in system \"" + std::string(system->getFullCref()) + "\"") 126 #define logError_ComponentNotInSystem(system, component) logError("System \"" + std::string(system->getFullCref()) + "\" does not contain component \"" + std::string(component) + "\"") 127 #define logError_ConnectionExistsAlready(crefA, crefB, system) logError("Connection <\"" + std::string(crefA) + "\", \"" + std::string(crefB) + "\"> exists already in system \"" + std::string(system->getFullCref()) + "\"") 128 #define logError_ConnectionNotInSystem(crefA, crefB, system) logError("Connection <\"" + std::string(crefA) + "\", \"" + std::string(crefB) + "\"> not found in system \"" + std::string(system->getFullCref()) + "\"") 129 #define logError_ConnectorNotInComponent(cref, component) logError("Connector \"" + std::string(cref) + "\" not found in component \"" + std::string(component->getFullCref()) + "\"") 130 #define logError_ConnectorNotInSystem(cref, system) logError("Connector \"" + std::string(cref) + "\" not found in system \"" + std::string(system->getFullCref()) + "\"") 131 #define logError_FMUCall(call, fmu) logError(std::string(call) + " failed for FMU \"" + std::string(fmu->getFullCref()) + "\"") 132 #define logError_Initialization(system) logError("Initialization of system \"" + std::string(system) + "\" failed") 133 #define logError_InternalError logError("internal error") 134 #define logError_InvalidIdent(cref) logError("\"" + std::string(cref) + "\" is not a valid ident") 135 #define logError_InvalidIdent(cref) logError("\"" + std::string(cref) + "\" is not a valid ident") 136 #define logError_ModelInWrongState(model) logError("Model \"" + std::string(model->getCref()) + "\" is in wrong model state") 137 #define logError_ModelNotInScope(cref) logError("Model \"" + std::string(cref) + "\" does not exist in the scope") 138 #define logError_NoConnectorsInTLMBus(cref) logError("No connectors in TLM bus: \"" + std::string(cref) + "\"") 139 #define logError_NotForExternalModels logError("Not available for external models") 140 #define logError_NotForScSystem logError("Not available for strongly coupled systems") 141 #define logError_NotForTlmSystem logError("Not available for TLM systems") 142 #define logError_NotImplemented logError("Not implemented") 143 #define logError_OnlyForExternalModels logError("Only available for TLM sub models (aka external models)") 144 #define logError_OnlyForModel logError("Only implemented for model identifiers") 145 #define logError_OnlyForRealInputs(cref) logError("Signal \"" + std::string(cref) + "\" is not a real input signal") 146 #define logError_OnlyForSystemTLM logError("Only available for TLM systems") 147 #define logError_OnlyForSystemWC logError("Only available for WC systems") 148 #define logError_ResetFailed(system) logError("failed to reset system \"" + std::string(system) + "\" to instantiation mode") 149 #define logError_SubSystemNotInSystem(system, subsystem) logError("System \"" + std::string(system) + "\" does not contain subsystem \"" + std::string(subsystem) + "\"") 150 #define logError_SystemNotInModel(model, system) logError("Model \"" + std::string(model) + "\" does not contain system \"" + std::string(system) + "\"") 151 #define logError_Termination(system) logError("Termination of system \"" + std::string(system) + "\" failed") 152 #define logError_TlmBusNotInComponent(cref, component) logError("TLM bus connector \"" + std::string(cref) + "\" not found in component \"" + std::string(component->getFullCref()) + "\"") 153 #define logError_TlmBusNotInSystem(cref, system) logError("TLM bus connector \"" + std::string(cref) + "\" not found in system \"" + std::string(system->getFullCref()) + "\"") 154 #define logError_UnknownSignal(cref) logError("Unknown signal \"" + std::string(cref) + "\"") 155 #define logError_UnknownTLMVariableType(vartype) logError("Unknown TLM variable type: \""+vartype+"\"") 156 #define logError_VariableTypeAlreadyInTLMBus(cref,vartype) logError("TLM bus connector \"" + std::string(cref) + "\" already contains a variable with type \"" + vartype + "\"") 157 #define logError_WrongSchema(name) logError("Wrong xml schema detected. Unexpected tag \"" + name + "\"") 158 #define logWarning_deprecated logWarning("Wrong/deprecated content detected but successfully loaded. Please re-export the SSP file to avoid this message.")
Log & operator=(Log const ©)
not implemented
static Log & getInstance()
Definition: Logging.cpp:70
std::ofstream logFile
Definition: Logging.h:85
void printStringToStream(std::ostream &stream, const std::string &type, const std::string &msg)
Definition: Logging.cpp:77
unsigned long limit
Definition: Logging.h:91
int logLevel
Definition: Logging.h:83
unsigned int numMessages
Definition: Logging.h:89
static void setLoggingCallback(void(*cb)(oms_message_type_enu_t type, const char *message))
Definition: Logging.h:64
oms_status_enu_t
Definition: Types.h:43
unsigned int numErrors
Definition: Logging.h:88
Log()
Definition: Logging.cpp:56
static oms_status_enu_t setLoggingLevel(int logLevel)
Definition: Logging.cpp:272
static void Debug(const std::string &msg)
Definition: Logging.cpp:193
static oms_status_enu_t Warning(const std::string &msg)
Definition: Logging.cpp:154
unsigned int numWarnings
Definition: Logging.h:87
bool progress
Definition: Logging.h:94
oms_message_type_enu_t
Message types used by the logging mechanism.
Definition: Types.h:156
std::string filename
Definition: Logging.h:84
static const int getLoggingLevel()
Definition: Logging.cpp:288
int percent
Definition: Logging.h:95
static oms_status_enu_t Error(const std::string &msg, const std::string &function)
Definition: Logging.cpp:170
static void Trace(const std::string &function, const std::string &file, const long line)
Definition: Logging.cpp:215
static bool DebugEnabled()
Definition: Logging.cpp:187
static void TerminateBar()
Definition: Logging.cpp:324
unsigned long size
Definition: Logging.h:92
static void Info(const std::string &msg)
Definition: Logging.cpp:141
static void setMaxLogFileSize(const unsigned long size)
Definition: Logging.h:62
static bool TraceEnabled()
Definition: Logging.cpp:209
static oms_status_enu_t setLogFile(const std::string &filename)
Definition: Logging.cpp:233
static void ProgressBar(double start, double stop, double value)
Definition: Logging.cpp:294
void(* cb)(oms_message_type_enu_t type, const char *message)
Definition: Logging.h:97
~Log()
Definition: Logging.cpp:64
std::mutex m
Definition: Logging.h:86