LogIt
Logging in quasar is handled by the LogIt component. For instructions on how to use LogIt generally, i.e. how to log specific messages from a quasar server please refer to the LogIt repository.
Initializing LogIt in the Quasar Server code
sending commands to some target hardware (e.g. calling some 3rd party API)
accepting input (e.g. handling OPC-UA client item writes and method calls)
handling hardware disconnection/reconnection events
// file: QuasarServer.h
virtual void initializeLogIt();
// file: QuasarServer.cpp
void QuasarServer::initializeLogIt()
#ifndef COMMON_INCLUDE_LOGITCOMPONENTIDS_H_
#define COMMON_INCLUDE_LOGITCOMPONENTIDS_H_
#include <LogItStaticDefinitions.h>
Log::LogComponentHandle HW_API_CALLS;
Log::LogComponentHandle AS_WRITES;
Log::LogComponentHandle AS_UPDATES;
#endif /* COMMON_INCLUDE_LOGITCOMPONENTIDS_H_ */
void QuasarServer::initializeLogIt()
{
Log::initializeLogging();
HW_API_CALLS = Log::registerLoggingComponent("HARDWARE_API_CALLS");
AS_WRITES = Log::registerLoggingComponent("ADDRESS_SPACE_WRITES");
AS_UPDATES = Log::registerLoggingComponent("ADDRESS_SPACE_UPDATES");
LOG(Log::INF) << "Logging initialized.";
}
LOG(Log::INF, HW_API_CALLS) << "Use the HW_API_CALLS component to log messages related to hardware API calls";
LOG(Log::INF, AS_WRITES) << "Use the AS_WRITES component to log messages related to input via the address space, e.g. client writes and method calls";
LOG(Log::INF, AS_UPDATES) << "Use the AS_UPDATES component to log messages related to output via the address space, e.g. updating OPC items based on events received from the hardware";
Setting LogIt Component Verbosity
Logging via LogIt is woven into the fabric of a quasar server. This allows for an integrated approach to logging that allows you to configure the verbosity of logging components both
initially, via the quasar server XML configuration
dynamically, via an OPC-UA client
Initial Verbosity: Via Server Config XML
The initial per-component verbosity can be configured in the server configuration XML file. Taking the component IDs from the sample code above (namely HW_API_CALLS, AS_WRITES, AS_UPDATES), the initial per-component verbosity can be configured in the server configuration file in the StandardMetaData root element as per the sample XML snippet below
<StandardMetaData>
<Log>
<GeneralLogLevel logLevel="INF"/>
<ComponentLogLevels>
<ComponentLogLevel componentName="HARDWARE_API_CALLS" logLevel="DBG"/>
<ComponentLogLevel componentName="ADDRESS_SPACE_WRITES" logLevel="TRC"/>
<ComponentLogLevel componentName="ADDRESS_SPACE_UPDATES" logLevel="WRN"/>
</ComponentLogLevels>
</Log>
</StandardMetaData>
Runtime Verbosity: Via an OPC_UA client
Quasar Framework Maintainers: Dealing with LogIt as a Git Submodule
Note that LogIt is its own independent component (it is used outside of quasar). So, the quasar repository does not have its own local copy of LogIt source code - quasar references LogIt source code in the LogIt repo as a git submodule. This section describes how maintainers of the quasar framework upgrade to newer versions of LogIt etc.
Which Version of LogIt is Quasar Using Now?
Release versions of quasar should use only tagged versions (i.e. releases) of LogIt. Assuming you have quasar cloned (recursively!) to your development environment… check which LogIt tag is currently in use via command git submodule status
$ git submodule status
17d9805db6bbbfd94cbd8e80b3e2542c356b7169 LogIt (v0.1.0)
Changing the Version of LogIt Quasar Uses
So, let’s say there’s a new LogIt version -a LogIt tag- that quasar should be using. There are 2 stages to updating to the new version
If LogIt uses new source files then update file FrameworkInternals/original_files.txt to reflect the modified source file list.
Update the submodule tag. Described below
According to this content, the procedure for updating the LogIt submodule to the next tag is
cd LogIt
git checkout vNewTag
cd ..
git add LogIt
git commit -m "moved LogIt to vNewTag"
git push
Then your fellow quasar maintainers update their environments with
git pull
git submodule update --init --recursive