include/private/namespaceconfigurations.hpp \
include/private/namespaceconfigurationsimpl.hpp \
include/private/namespacevalidator.hpp \
+ include/private/stdstreamlogger.hpp \
include/private/syncstorageimpl.hpp \
include/private/system.hpp \
include/private/timer.hpp \
src/publisherid.cpp \
src/rejectedbybackend.cpp \
src/rejectedbysdl.cpp \
+ src/stdstreamlogger.cpp \
src/syncstorage.cpp \
src/syncstorageimpl.cpp \
src/system.cpp \
m4_define([SDL_MAJOR], [1])
m4_define([SDL_MINOR], [0])
-m4_define([SDL_MICRO], [1])
+m4_define([SDL_MICRO], [2])
# SDL ABI version with libtool
#
# Change the numbers just before release.
m4_define([SDL_CURRENT], [1])
-m4_define([SDL_REVISION], [1])
+m4_define([SDL_REVISION], [2])
m4_define([SDL_AGE], [0])
AC_INIT([shareddatalayer], [SDL_MAJOR.SDL_MINOR.SDL_MICRO], [], [], [https://gerrit.o-ran-sc.org/r/admin/repos/ric-plt/sdl])
AX_BOOST_FILESYSTEM
PKG_PROG_PKG_CONFIG
-AC_DEFINE([HAVE_SYSTEMLOGGER], [1], [Have systemlogger])
-AM_CONDITIONAL([SYSTEMLOGGER], [test xtrue])
+AC_DEFINE([HAVE_SYSTEMLOGGER], [0], [Have systemlogger])
+AM_CONDITIONAL([SYSTEMLOGGER], [test "xyes" = "xno"])
SDL_CONF_DIR=$sysconfdir/$PACKAGE_NAME.d
AC_SUBST(SDL_CONF_DIR)
--- /dev/null
+/*
+ Copyright (c) 2018-2019 Nokia.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef SHAREDDATALAYER_STDSTREAMLOGGER_HPP_
+#define SHAREDDATALAYER_STDSTREAMLOGGER_HPP_
+
+#include <memory>
+#include <string>
+#include "private/logger.hpp"
+
+namespace shareddatalayer
+{
+ class StdStreamLogger: public Logger
+ {
+ public:
+ explicit StdStreamLogger(const std::string& prefix);
+
+ ~StdStreamLogger();
+
+ std::ostream& emerg() override;
+
+ std::ostream& alert() override;
+
+ std::ostream& crit() override;
+
+ std::ostream& error() override;
+
+ std::ostream& warning() override;
+
+ std::ostream& notice() override;
+
+ std::ostream& info() override;
+
+ std::ostream& debug() override;
+
+ private:
+ const std::string prefix;
+ std::unique_ptr<std::ostream> osEmerg;
+ std::unique_ptr<std::ostream> osAlert;
+ std::unique_ptr<std::ostream> osCrit;
+ std::unique_ptr<std::ostream> osError;
+ std::unique_ptr<std::ostream> osWarning;
+ std::unique_ptr<std::ostream> osNotice;
+ std::unique_ptr<std::ostream> osInfo;
+ std::unique_ptr<std::ostream> osDebug;
+ };
+}
+
+#endif
#include "config.h"
#include <memory>
+#include <ostream>
#include <string>
#include "private/createlogger.hpp"
+#include "private/stdstreamlogger.hpp"
#if HAVE_SYSTEMLOGGER
#include "private/systemlogger.hpp"
#endif
#if HAVE_SYSTEMLOGGER
return std::shared_ptr<Logger>(new SystemLogger(prefix));
#else
-#error "Need to compile with at least one logging backend"
+ return std::shared_ptr<Logger>(new StdStreamLogger(prefix));
#endif
}
void shareddatalayer::logDebugOnce(const std::string& msg) noexcept
{
auto logger(createLogger(SDL_LOG_PREFIX));
- logger->debug() << msg;
+ logger->debug() << msg << std::endl;
}
void shareddatalayer::logErrorOnce(const std::string& msg) noexcept
{
auto logger(createLogger(SDL_LOG_PREFIX));
- logger->error() << msg;
+ logger->error() << msg << std::endl;
}
void shareddatalayer::logInfoOnce(const std::string& msg) noexcept
{
auto logger(createLogger(SDL_LOG_PREFIX));
- logger->info() << msg;
+ logger->info() << msg << std::endl;
}
--- /dev/null
+/*
+ Copyright (c) 2018-2019 Nokia.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "private/stdstreamlogger.hpp"
+#include <iostream>
+#include <sstream>
+#include <syslog.h>
+#include <boost/iostreams/stream.hpp>
+#include <boost/iostreams/concepts.hpp>
+
+using namespace shareddatalayer;
+
+namespace
+{
+ class Sink: public boost::iostreams::sink
+ {
+ public:
+ Sink(const std::string& prefix, int level): prefix(prefix), level(level) { }
+
+ ~Sink() { }
+
+ std::streamsize write(const char* s, std::streamsize n);
+
+ private:
+ const std::string prefix;
+ const int level;
+ };
+}
+
+std::streamsize Sink::write(const char* s, std::streamsize n)
+{
+ if (level < LOG_ERR)
+ std::cout << prefix << ": " << std::string(s, n);
+ else
+ std::cerr << prefix << ": " << std::string(s, n);
+ return n;
+}
+
+StdStreamLogger::StdStreamLogger(const std::string& prefix):
+ prefix(prefix)
+{
+}
+
+StdStreamLogger::~StdStreamLogger()
+{
+}
+
+std::ostream& StdStreamLogger::emerg()
+{
+ if (osEmerg == nullptr)
+ osEmerg.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_EMERG)));
+ return *osEmerg;
+}
+
+std::ostream& StdStreamLogger::alert()
+{
+ if (osAlert == nullptr)
+ osAlert.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_ALERT)));
+ return *osAlert;
+}
+
+std::ostream& StdStreamLogger::crit()
+{
+ if (osCrit == nullptr)
+ osCrit.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_CRIT)));
+ return *osCrit;
+}
+
+std::ostream& StdStreamLogger::error()
+{
+ if (osError == nullptr)
+ osError.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_ERR)));
+ return *osError;
+}
+
+std::ostream& StdStreamLogger::warning()
+{
+ if (osWarning == nullptr)
+ osWarning.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_WARNING)));
+ return *osWarning;
+}
+
+std::ostream& StdStreamLogger::notice()
+{
+ if (osNotice == nullptr)
+ osNotice.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_NOTICE)));
+ return *osNotice;
+}
+
+std::ostream& StdStreamLogger::info()
+{
+ if (osInfo == nullptr)
+ osInfo.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_INFO)));
+ return *osInfo;
+}
+
+std::ostream& StdStreamLogger::debug()
+{
+ if (osDebug == nullptr)
+ osDebug.reset(new boost::iostreams::stream<Sink>(Sink(prefix, LOG_DEBUG)));
+ return *osDebug;
+}