Commit 9b468ff6 authored by Alessio Netti's avatar Alessio Netti

Fixes and streamlining

- Fixed some linking issues with the SensorNavigator
- dcdbpusher now uses the common logging interface to setup file and
command-line sinks
parent d35348f7
......@@ -24,6 +24,7 @@ debug: all
clean:
rm -f $(ANALYZER_LIBS) $(shell find . -name "*.o")
rm -f "../common/src/sensornavigator.o"
$(OBJS) : %.o : %.cpp
......@@ -40,7 +41,7 @@ install: install_analyzer
@echo " > make install_conf"
analyzers/%.o: CXXFLAGS+= $(PLUGINFLAGS)
SensorNavigator.o: CXXFLAGS+= $(PLUGINFLAGS)
../common/src/sensornavigator.o: CXXFLAGS+= $(PLUGINFLAGS)
libdcdbanalyzer_average.$(LIBEXT): analyzers/average/AverageAnalyzer.o analyzers/average/AverageConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
......@@ -2,8 +2,8 @@ include ../config.mk
include ../common.mk
CXXFLAGS = -std=c++11 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_NETWORK_ENABLE_HTTPS -O2 -g -Wall -Wno-unused-function -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-unused-variable -DBOOST_LOG_DYN_LINK -I$(DCDBBASEPATH)/dcdb/common/include -I$(DCDBDEPLOYPATH)/include -I$(DCDBDEPSPATH)/cpp-netlib-0.12.0-final/deps/asio/asio/include -DVERSION=\"$(VERSION)\"
LIBS = -L../deps/mosquitto_build/lib -L$(DCDBDEPLOYPATH)/lib/ -ldl -lmosquitto -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lboost_regex -lpthread -lcrypto -lssl -lcppnetlib-server-parsers -lcppnetlib-uri -rdynamic
OBJS = dcdbpusher.o Configuration.o MQTTPusher.o HttpsServer.o ../analytics/AnalyticsManager.o ../common/src/sensornavigator.o
LIBS = -L$(DCDBDEPLOYPATH)/lib/ -ldl -lmosquitto -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lboost_regex -lpthread -lcrypto -lssl -lcppnetlib-server-parsers -lcppnetlib-uri -rdynamic
OBJS = dcdbpusher.o Configuration.o MQTTPusher.o HttpsServer.o ../analytics/AnalyticsManager.o ../common/src/sensornavigator.o ../common/src/logging.o
TARGET = dcdbpusher
PLUGINS = procfs pdu sysfs ipmi bacnet snmp gpfsmon tester
......@@ -29,7 +29,7 @@ debug: CXXFLAGS += -DDEBUG
debug: all
clean:
rm -f $(PLUGIN_LIBS) $(TARGET) $(shell find . -name "*.o")
rm -f $(PLUGIN_LIBS) $(TARGET) $(OBJS) $(shell find ./sensors -name "*.o")
$(OBJS) : %.o : %.cpp
......@@ -49,7 +49,7 @@ install: $(TARGET) install_lib
BACNET_SRC:= $(shell find $(DCDBDEPSPATH) -name "bacnet-stack-*" -type d)
sensors/%.o: CXXFLAGS+= $(PLUGINFLAGS)
sensors/bacnet/%.o: CXXFLAGS+= -I$(BACNET_SRC)/include -I$(BACNET_SRC)/ports/$(BACNET_PORT)
../analytics/SensorNavigator.o: CXXFLAGS+= $(PLUGINFLAGS)
../common/src/sensornavigator.o: CXXFLAGS+= $(PLUGINFLAGS)
libdcdbplugin_sysfs.$(LIBEXT): sensors/sysfs/SysfsSensorGroup.o sensors/sysfs/SysfsConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
......
......@@ -203,18 +203,10 @@ int main(int argc, char** argv) {
}
//init LOGGING
boost::log::add_common_attributes();
initLogging();
//set up logger to command line
auto cmdSink = boost::log::add_console_log(
std::cout,
boost::log::keywords::format = (boost::log::expressions::stream //only print timestamp (without date), severity and message to terminal
<< "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]"
<< " <" << boost::log::trivial::severity << ">"
<< ": " << boost::log::expressions::smessage
),
boost::log::keywords::filter = (boost::log::trivial::severity >= boost::log::trivial::info)
);
auto cmdSink = setupCmdLogger();
//get logger instance
boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
......@@ -284,21 +276,7 @@ int main(int argc, char** argv) {
//we now should know where the writable tempdir is
//set up logger to file
auto fileSink = boost::log::add_file_log(
boost::log::keywords::file_name = pluginSettings.tempdir + "dcdb_%N.log", // number logfiles ascending
boost::log::keywords::rotation_size = 10 * 1024 * 1024, //rotate logfile every 10 MiB
//boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), //Throws bad year-exception for no obvious reason
boost::log::keywords::format = // format: LineID [Timestamp] ThreadID <severity>: Message
( boost::log::expressions::stream
<< boost::log::expressions::attr< unsigned int >("LineID")
<< " [" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d, %H:%M:%S") << "]"
<< " " << boost::log::expressions::attr<boost::log::attributes::current_thread_id::value_type >("ThreadID")
<< " <" << boost::log::trivial::severity << ">"
<< ": " << boost::log::expressions::smessage
),
boost::log::keywords::filter = (boost::log::trivial::severity >= boost::log::trivial::trace),
boost::log::keywords::auto_flush = true
);
auto fileSink = setupFileLogger(pluginSettings.tempdir, std::string("dcdbpusher"));
//severity level may be overwritten (per option or config-file) --> set it according to globalSettings
fileSink->set_filter(boost::log::trivial::severity >= globalSettings.logLevelFile);
......
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