The syslog() helper for logging an error is not necessary, leave it out of the API and move it to a new private utils module. Signed-off-by: Lukáš Hrázký <lhrazky@xxxxxxxxxx> --- include/spice-streaming-agent/error.hpp | 8 -------- src/Makefile.am | 1 + src/cursor-updater.cpp | 1 + src/spice-streaming-agent.cpp | 3 ++- src/utils.hpp | 24 ++++++++++++++++++++++++ 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/utils.hpp diff --git a/include/spice-streaming-agent/error.hpp b/include/spice-streaming-agent/error.hpp index 2993dbb..3202d78 100644 --- a/include/spice-streaming-agent/error.hpp +++ b/include/spice-streaming-agent/error.hpp @@ -9,7 +9,6 @@ #include <stdexcept> #include <string> -#include <syslog.h> namespace spice { @@ -21,13 +20,6 @@ public: Error(const std::string &message) : std::runtime_error(message) {} }; -template<class T> -const T &syslog(const T &error) noexcept -{ - ::syslog(LOG_ERR, "%s\n", error.what()); - return error; -} - }} // namespace spice::streaming_agent #endif // SPICE_STREAMING_AGENT_ERROR_HPP diff --git a/src/Makefile.am b/src/Makefile.am index 36a5d8a..dc64c29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,6 +65,7 @@ spice_streaming_agent_SOURCES = \ jpeg.hpp \ stream-port.cpp \ stream-port.hpp \ + utils.hpp \ $(NULL) if HAVE_GST diff --git a/src/cursor-updater.cpp b/src/cursor-updater.cpp index c27131b..779f878 100644 --- a/src/cursor-updater.cpp +++ b/src/cursor-updater.cpp @@ -14,6 +14,7 @@ #include <memory> #include <vector> +#include <syslog.h> #include <unistd.h> #include <X11/extensions/Xfixes.h> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp index 4b44df3..1eb8e1b 100644 --- a/src/spice-streaming-agent.cpp +++ b/src/spice-streaming-agent.cpp @@ -9,6 +9,7 @@ #include "cursor-updater.hpp" #include "frame-log.hpp" #include "stream-port.hpp" +#include "utils.hpp" #include <spice-streaming-agent/error.hpp> #include <spice/stream-device.h> @@ -254,7 +255,7 @@ do_capture(StreamPort &stream_port, FrameLog &frame_log) try { stream_port.send<FrameMessage>(frame.buffer, frame.buffer_size); } catch (const WriteError& e) { - syslog(e); + utils::syslog(e); break; } frame_log.log_stat("Sent frame"); diff --git a/src/utils.hpp b/src/utils.hpp new file mode 100644 index 0000000..64cb538 --- /dev/null +++ b/src/utils.hpp @@ -0,0 +1,24 @@ +/* \copyright + * Copyright 2018 Red Hat Inc. All rights reserved. + */ + +#ifndef SPICE_STREAMING_AGENT_UTILS_HPP +#define SPICE_STREAMING_AGENT_UTILS_HPP + +#include <syslog.h> + + +namespace spice { +namespace streaming_agent { +namespace utils { + +template<class T> +const T &syslog(const T &error) noexcept +{ + ::syslog(LOG_ERR, "%s\n", error.what()); + return error; +} + +}}} // namespace spice::streaming_agent::utils + +#endif // SPICE_STREAMING_AGENT_UTILS_HPP -- 2.19.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel