OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment.
Loading...
Searching...
No Matches
Logging.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
14 * ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the Open Source Modelica
17 * Consortium (OSMC) Public License (OSMC-PL) are obtained
18 * from OSMC, either from the above address,
19 * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
20 * http://www.openmodelica.org, and in the OpenModelica distribution.
21 * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
22 *
23 * This program is distributed WITHOUT ANY WARRANTY; without
24 * even the implied warranty of MERCHANTABILITY or FITNESS
25 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
26 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
27 *
28 * See the full OSMC Public License conditions for more details.
29 *
30 */
31
32#pragma once
33
34#include "OMSimulator/Types.h"
35
36#include <string>
37
38namespace oms
39{
40 namespace Log
41 {
42 // The functions in the Internal namespace are not meant to be used directly.
43 // They are intended to be used by the macros defined below.
44 namespace Internal
45 {
46 void Info(const std::string &msg);
47 oms_status_enu_t Warning(const std::string &msg);
48 oms_status_enu_t Error(const std::string &msg, const std::string &function);
49
50 bool DebugEnabled();
51 bool TraceEnabled();
52
53 void Debug(const std::string &msg);
54 void Trace(const std::string &function, const std::string &file, const long line);
55 }
56
57 void ProgressBar(double start, double stop, double value);
58 void TerminateBar();
59
60 void SetCallback(void (*cb)(oms_message_type_enu_t type, const char *message));
61 oms_status_enu_t SetLogFile(const std::string &filename);
62
63 oms_status_enu_t SetLoggingLevel(int logLevel);
64 const int GetLoggingLevel();
65
66 void SetMaxLogFileSize(const unsigned long size);
67 }
68}
69
70#define logInfo(msg) oms::Log::Internal::Info(msg)
71#define logWarning(msg) oms::Log::Internal::Warning(msg)
72#define logError(msg) oms::Log::Internal::Error(msg, __func__)
73
74#if !defined(NDEBUG)
75 #define logDebugEnabled() oms::Log::Internal::DebugEnabled()
76 #define logTraceEnabled() oms::Log::Internal::TraceEnabled()
77
78 #define logDebug(msg) oms::Log::Internal::Debug(msg)
79 #define logTrace() oms::Log::Internal::Trace(__func__, __FILE__, __LINE__)
80#else
81 #define logDebugEnabled() (false)
82 #define logTraceEnabled() (false)
83
84 #define logDebug(msg) ((void)0)
85 #define logTrace() ((void)0)
86#endif
87
88// common error messages
89#define logError_AlreadyInScope(cref) logError("\"" + std::string(cref) + "\" already exists in the scope")
90#define logError_BusAndConnectorNotSameModel(bus, connector) logError("Bus \"" + std::string(bus) + "\" and connector \"" + std::string(connector) + "\" do not belong to same model")
91#define logError_BusAndConnectorNotSameSystem(bus, connector) logError("Bus \"" + std::string(bus) + "\" and connector \"" + std::string(connector) + "\" do not belong to same system")
92#define logError_BusNotInComponent(cref, component) logError("Bus connector \"" + std::string(cref) + "\" not found in component \"" + std::string(component->getFullCref()) + "\"")
93#define logError_BusNotInSystem(cref, system) logError("Bus connector \"" + std::string(cref) + "\" not found in system \"" + std::string(system->getFullCref()) + "\"")
94#define logError_ComponentNotInSystem(system, component) logError("System \"" + std::string(system->getFullCref()) + "\" does not contain component \"" + std::string(component) + "\"")
95#define logError_ConnectionExistsAlready(crefA, crefB, system) logError("Connection <\"" + std::string(crefA) + "\", \"" + std::string(crefB) + "\"> exists already in system \"" + std::string(system->getFullCref()) + "\"")
96#define logError_ConnectionNotInSystem(crefA, crefB, system) logError("Connection <\"" + std::string(crefA) + "\", \"" + std::string(crefB) + "\"> not found in system \"" + std::string(system->getFullCref()) + "\"")
97#define logError_ConnectorNotInComponent(cref, component) logError("Connector \"" + std::string(cref) + "\" not found in component \"" + std::string(component->getFullCref()) + "\"")
98#define logError_ConnectorNotInSystem(cref, system) logError("Connector \"" + std::string(cref) + "\" not found in system \"" + std::string(system->getFullCref()) + "\"")
99#define logError_FMUCall(call, fmu) logError(std::string(call) + " failed for FMU \"" + std::string(fmu->getFullCref()) + "\"")
100#define logError_Initialization(system) logError("Initialization of system \"" + std::string(system) + "\" failed")
101#define logError_InternalError logError("internal error")
102#define logError_InvalidIdent(cref) logError("\"" + std::string(cref) + "\" is not a valid ident")
103#define logError_InvalidIdent(cref) logError("\"" + std::string(cref) + "\" is not a valid ident")
104#define logError_ModelInWrongState(cref) logError("Model \"" + std::string(cref) + "\" is in wrong model state")
105#define logError_ModelNotInScope(cref) logError("Model \"" + std::string(cref) + "\" does not exist in the scope")
106#define logError_NotForScSystem logError("Not available for strongly coupled systems")
107#define logError_NotImplemented logError("Not implemented")
108#define logError_OnlyForModel logError("Only implemented for model identifiers")
109#define logError_OnlyForRealInputs(cref) logError("Signal \"" + std::string(cref) + "\" is not a real input signal")
110#define logError_OnlyForSystemWC logError("Only available for WC systems")
111#define logError_ResetFailed(system) logError("failed to reset system \"" + std::string(system) + "\" to instantiation mode")
112#define logError_SubSystemNotInSystem(system, subsystem) logError("System \"" + std::string(system) + "\" does not contain subsystem \"" + std::string(subsystem) + "\"")
113#define logError_SystemNotInModel(model, system) logError("Model \"" + std::string(model) + "\" does not contain system \"" + std::string(system) + "\"")
114#define logError_Termination(system) logError("Termination of system \"" + std::string(system) + "\" failed")
115#define logError_UnknownSignal(cref) logError("Unknown signal \"" + std::string(cref) + "\"")
116#define logError_WrongSchema(name) logError("Wrong xml schema detected. Unexpected tag \"" + name + "\"")
117#define logWarning_deprecated logWarning("Wrong/deprecated content detected but successfully loaded. Please re-export the SSP file to avoid this message.")
bool DebugEnabled()
Definition Logging.cpp:203
void Info(const std::string &msg)
Definition Logging.cpp:160
oms_status_enu_t Error(const std::string &msg, const std::string &function)
Definition Logging.cpp:187
void Trace(const std::string &function, const std::string &file, const long line)
Definition Logging.cpp:228
void Debug(const std::string &msg)
Definition Logging.cpp:208
bool TraceEnabled()
Definition Logging.cpp:223
oms_status_enu_t Warning(const std::string &msg)
Definition Logging.cpp:172
oms_status_enu_t SetLoggingLevel(int logLevel)
Definition Logging.cpp:283
void ProgressBar(double start, double stop, double value)
Definition Logging.cpp:313
void TerminateBar()
Definition Logging.cpp:341
void SetCallback(void(*cb)(oms_message_type_enu_t type, const char *message))
Definition Logging.cpp:308
oms_status_enu_t SetLogFile(const std::string &filename)
Definition Logging.cpp:245
const int GetLoggingLevel()
Definition Logging.cpp:298
void SetMaxLogFileSize(const unsigned long size)
Definition Logging.cpp:303
Definition AlgLoop.h:45