-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Logging] Introducing Provider/Receiver pattern for logging #1831
Changes from 23 commits
dbb5478
9cbaf5a
bddd31f
360deb9
28d7734
2c2956c
24a0b13
50f88ca
294e531
a5bf465
c390e4c
d22b9a9
960e9ba
546db2c
4072334
ee26111
bcf6d54
c4f4cd7
e0729f6
2d6cee1
2b4d197
2c53961
9ceee76
76707d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ namespace eCAL | |
settings_.ClearHostFilter(); // There is no global host filter | ||
|
||
// Initialize eCAL | ||
eCAL::Initialize("", eCAL::Init::Default | eCAL::Init::Monitoring); | ||
eCAL::Initialize("eCALRec-Server", eCAL::Init::Default | eCAL::Init::Monitoring); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Init::Monitoring" is directly included [misc-include-cleaner] eCAL::Initialize("eCALRec-Server", eCAL::Init::Default | eCAL::Init::Monitoring);
^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Initialize" is directly included [misc-include-cleaner] app/rec/rec_server_core/src/rec_server_impl.cpp:21: - #include "recorder_settings.h"
+ #include "ecal/ecal_core.h"
+ #include "recorder_settings.h" |
||
|
||
// Start FTP Server | ||
ftp_server_->start(5); | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -41,42 +41,49 @@ namespace eCAL | |||||
{ | ||||||
namespace Sinks | ||||||
{ | ||||||
namespace Console | ||||||
struct Sink | ||||||
{ | ||||||
struct Configuration | ||||||
{ | ||||||
bool enable { true }; //!< Enable console logging (Default: true) | ||||||
eCAL_Logging_Filter filter_log_con { log_level_error | log_level_fatal }; /*!< Log messages logged to console (all, info, warning, error, fatal, debug1, debug2, debug3, debug4) | ||||||
(Default: info, warning, error, fatal)*/ | ||||||
}; | ||||||
} | ||||||
bool enable; //!< Enable sink | ||||||
eCAL_Logging_Filter filter_log; //!< Log messages logged (all, info, warning, error, fatal, debug1, debug2, debug3, debug4) | ||||||
}; | ||||||
|
||||||
namespace File | ||||||
{ | ||||||
struct Configuration | ||||||
{ | ||||||
bool enable { false }; //!< Enable file logging (Default: false) | ||||||
std::string path { "" }; //!< Path to log file (Default: "") | ||||||
eCAL_Logging_Filter filter_log_file { log_level_none }; /*!< Log messages logged into file system (all, info, warning, error, fatal, debug1, debug2, debug3, debug4) | ||||||
(Default: info, warning, error, fatal)*/ | ||||||
std::string path { "" }; //!< Path to log file (Default: "") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: redundant string initialization [readability-redundant-string-init]
Suggested change
|
||||||
}; | ||||||
} | ||||||
|
||||||
namespace UDP | ||||||
{ | ||||||
struct ReceiverConfiguration | ||||||
{ | ||||||
bool enable { false }; //!< Enable UDP receiver (Default: false) | ||||||
unsigned int port { 14001 }; //!< UDP port number (Default: 14001) | ||||||
}; | ||||||
|
||||||
struct ProviderConfiguration | ||||||
{ | ||||||
unsigned int port { 14001 }; //!< UDP port number (Default: 14001) | ||||||
}; | ||||||
|
||||||
struct Configuration | ||||||
{ | ||||||
bool enable { true }; //!< Enable UDP logging (Default: false) | ||||||
unsigned int port { 14001 }; //!< UDP port number (Default: 14001) | ||||||
eCAL_Logging_Filter filter_log_udp { log_filter_default }; //!< Log messages logged via udp network (Default: info, warning, error, fatal) | ||||||
ReceiverConfiguration receiver; | ||||||
ProviderConfiguration provider; | ||||||
}; | ||||||
} | ||||||
|
||||||
struct Configuration | ||||||
{ | ||||||
Console::Configuration console; | ||||||
File::Configuration file; | ||||||
UDP::Configuration udp; | ||||||
Sink console { true, log_level_error | log_level_fatal}; //!< default: true, log_level_error | ||||||
Sink file { false, log_level_none }; //!< default: false, log_level_none | ||||||
Sink udp { true, log_filter_default }; //!< default: true, log_filter_default | ||||||
|
||||||
File::Configuration file_config; | ||||||
UDP::Configuration udp_config; | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks very clean like this! |
||||||
}; | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,12 @@ namespace eCAL | |
{ | ||
namespace Init | ||
{ | ||
static const unsigned int Publisher = 0x001; | ||
static const unsigned int Subscriber = 0x002; | ||
static const unsigned int Service = 0x004; | ||
static const unsigned int Monitoring = 0x008; | ||
static const unsigned int Logging = 0x010; | ||
static const unsigned int TimeSync = 0x020; | ||
static const unsigned int Publisher = 0x001; | ||
static const unsigned int Subscriber = 0x002; | ||
static const unsigned int Service = 0x004; | ||
static const unsigned int Monitoring = 0x008; | ||
static const unsigned int Logging = 0x010; | ||
static const unsigned int TimeSync = 0x020; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could realign, so you don't get any changes in this file |
||
|
||
static const unsigned int All = Publisher | ||
| Subscriber | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,61 +576,79 @@ namespace YAML | |
/____/\___/\_, /\_, /_/_//_/\_, / | ||
/___//___/ /___/ | ||
*/ | ||
Node convert<eCAL::Logging::Sinks::UDP::Configuration>::encode(const eCAL::Logging::Sinks::UDP::Configuration& config_) | ||
|
||
Node convert<eCAL::Logging::Sinks::UDP::ReceiverConfiguration>::encode(const eCAL::Logging::Sinks::UDP::ReceiverConfiguration& config_) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::UDP::ReceiverConfiguration" is directly included [misc-include-cleaner] ecal/core/src/config/configuration_to_yaml.cpp:1: + #include "ecal/config/logging.h" |
||
{ | ||
Node node; | ||
node["enable"] = config_.enable; | ||
node["port"] = config_.port; | ||
node["level"] = LogLevelToVector(config_.filter_log_udp); | ||
return node; | ||
} | ||
|
||
bool convert<eCAL::Logging::Sinks::UDP::Configuration>::decode(const Node& node_, eCAL::Logging::Sinks::UDP::Configuration& config_) | ||
bool convert<eCAL::Logging::Sinks::UDP::ReceiverConfiguration>::decode(const Node& node_, eCAL::Logging::Sinks::UDP::ReceiverConfiguration& config_) | ||
{ | ||
AssignValue<bool>(config_.enable, node_, "enable"); | ||
AssignValue<unsigned int>(config_.port, node_, "port"); | ||
|
||
std::vector<std::string> tmp; | ||
AssignValue<std::vector<std::string>>(tmp, node_, "level"); | ||
config_.filter_log_udp = ParseLogLevel(tmp); | ||
return true; | ||
} | ||
|
||
Node convert<eCAL::Logging::Sinks::UDP::ProviderConfiguration>::encode(const eCAL::Logging::Sinks::UDP::ProviderConfiguration& config_) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::UDP::ProviderConfiguration" is directly included [misc-include-cleaner] Node convert<eCAL::Logging::Sinks::UDP::ProviderConfiguration>::encode(const eCAL::Logging::Sinks::UDP::ProviderConfiguration& config_)
^ |
||
{ | ||
Node node; | ||
node["port"] = config_.port; | ||
return node; | ||
} | ||
|
||
bool convert<eCAL::Logging::Sinks::UDP::ProviderConfiguration>::decode(const Node& node_, eCAL::Logging::Sinks::UDP::ProviderConfiguration& config_) | ||
{ | ||
AssignValue<unsigned int>(config_.port, node_, "port"); | ||
|
||
return true; | ||
} | ||
|
||
Node convert<eCAL::Logging::Sinks::Console::Configuration>::encode(const eCAL::Logging::Sinks::Console::Configuration& config_) | ||
Node convert<eCAL::Logging::Sinks::UDP::Configuration>::encode(const eCAL::Logging::Sinks::UDP::Configuration& config_) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::UDP::Configuration" is directly included [misc-include-cleaner] Node convert<eCAL::Logging::Sinks::UDP::Configuration>::encode(const eCAL::Logging::Sinks::UDP::Configuration& config_)
^ |
||
{ | ||
Node node; | ||
node["receiver"] = config_.receiver; | ||
node["provider"] = config_.provider; | ||
return node; | ||
} | ||
|
||
bool convert<eCAL::Logging::Sinks::UDP::Configuration>::decode(const Node& node_, eCAL::Logging::Sinks::UDP::Configuration& config_) | ||
{ | ||
AssignValue<eCAL::Logging::Sinks::UDP::ProviderConfiguration>(config_.provider, node_, "provider"); | ||
AssignValue<eCAL::Logging::Sinks::UDP::ReceiverConfiguration>(config_.receiver, node_, "receiver"); | ||
return true; | ||
} | ||
|
||
Node convert<eCAL::Logging::Sinks::Sink>::encode(const eCAL::Logging::Sinks::Sink& config_) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::Sink" is directly included [misc-include-cleaner] Node convert<eCAL::Logging::Sinks::Sink>::encode(const eCAL::Logging::Sinks::Sink& config_)
^ |
||
{ | ||
Node node; | ||
node["enable"] = config_.enable; | ||
node["level"] = LogLevelToVector(config_.filter_log_con); | ||
node["level"] = LogLevelToVector(config_.filter_log); | ||
return node; | ||
} | ||
|
||
bool convert<eCAL::Logging::Sinks::Console::Configuration>::decode(const Node& node_, eCAL::Logging::Sinks::Console::Configuration& config_) | ||
bool convert<eCAL::Logging::Sinks::Sink>::decode(const Node& node_, eCAL::Logging::Sinks::Sink& config_) | ||
{ | ||
AssignValue<bool>(config_.enable, node_, "enable"); | ||
std::vector<std::string> tmp; | ||
AssignValue<std::vector<std::string>>(tmp, node_, "level"); | ||
config_.filter_log_con = ParseLogLevel(tmp); | ||
config_.filter_log = ParseLogLevel(tmp); | ||
return true; | ||
} | ||
|
||
Node convert<eCAL::Logging::Sinks::File::Configuration>::encode(const eCAL::Logging::Sinks::File::Configuration& config_) | ||
{ | ||
Node node; | ||
node["enable"] = config_.enable; | ||
node["path"] = config_.path; | ||
node["level"] = LogLevelToVector(config_.filter_log_file); | ||
return node; | ||
} | ||
|
||
bool convert<eCAL::Logging::Sinks::File::Configuration>::decode(const Node& node_, eCAL::Logging::Sinks::File::Configuration& config_) | ||
{ | ||
AssignValue<bool>(config_.enable, node_, "enable"); | ||
AssignValue<std::string>(config_.path, node_, "path"); | ||
|
||
std::vector<std::string> tmp; | ||
AssignValue<std::vector<std::string>>(tmp, node_, "level"); | ||
config_.filter_log_file = ParseLogLevel(tmp); | ||
return true; | ||
} | ||
|
||
|
@@ -645,9 +663,11 @@ namespace YAML | |
|
||
bool convert<eCAL::Logging::Sinks::Configuration>::decode(const Node& node_, eCAL::Logging::Sinks::Configuration& config_) | ||
{ | ||
AssignValue<eCAL::Logging::Sinks::Console::Configuration>(config_.console, node_, "console"); | ||
AssignValue<eCAL::Logging::Sinks::File::Configuration>(config_.file, node_, "file"); | ||
AssignValue<eCAL::Logging::Sinks::UDP::Configuration>(config_.udp, node_, "udp"); | ||
AssignValue<eCAL::Logging::Sinks::Sink>(config_.console, node_, "console"); | ||
AssignValue<eCAL::Logging::Sinks::Sink>(config_.file, node_, "file"); | ||
AssignValue<eCAL::Logging::Sinks::Sink>(config_.udp, node_, "udp"); | ||
AssignValue<eCAL::Logging::Sinks::UDP::Configuration>(config_.udp_config, node_, "udp"); | ||
AssignValue<eCAL::Logging::Sinks::File::Configuration>(config_.file_config, node_, "file"); | ||
return true; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,19 +298,19 @@ namespace YAML | |
/___//___/ /___/ | ||
*/ | ||
template<> | ||
struct convert<eCAL::Logging::Sinks::UDP::Configuration> | ||
struct convert<eCAL::Logging::Sinks::UDP::ReceiverConfiguration> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::UDP::ReceiverConfiguration" is directly included [misc-include-cleaner] ecal/core/src/config/configuration_to_yaml.h:26: - #include <ecal/config/configuration.h>
+ #include "ecal/config/logging.h"
+ #include <ecal/config/configuration.h> |
||
{ | ||
static Node encode(const eCAL::Logging::Sinks::UDP::Configuration& config_); | ||
static Node encode(const eCAL::Logging::Sinks::UDP::ReceiverConfiguration& config_); | ||
|
||
static bool decode(const Node& node_, eCAL::Logging::Sinks::UDP::Configuration& config_); | ||
static bool decode(const Node& node_, eCAL::Logging::Sinks::UDP::ReceiverConfiguration& config_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a bit strange that |
||
}; | ||
|
||
template<> | ||
struct convert<eCAL::Logging::Sinks::Console::Configuration> | ||
struct convert<eCAL::Logging::Sinks::UDP::ProviderConfiguration> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::UDP::ProviderConfiguration" is directly included [misc-include-cleaner] struct convert<eCAL::Logging::Sinks::UDP::ProviderConfiguration>
^ |
||
{ | ||
static Node encode(const eCAL::Logging::Sinks::Console::Configuration& config_); | ||
static Node encode(const eCAL::Logging::Sinks::UDP::ProviderConfiguration& config_); | ||
|
||
static bool decode(const Node& node_, eCAL::Logging::Sinks::Console::Configuration& config_); | ||
static bool decode(const Node& node_, eCAL::Logging::Sinks::UDP::ProviderConfiguration& config_); | ||
}; | ||
|
||
template<> | ||
|
@@ -321,6 +321,22 @@ namespace YAML | |
static bool decode(const Node& node_, eCAL::Logging::Sinks::File::Configuration& config_); | ||
}; | ||
|
||
template<> | ||
struct convert<eCAL::Logging::Sinks::UDP::Configuration> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::UDP::Configuration" is directly included [misc-include-cleaner] struct convert<eCAL::Logging::Sinks::UDP::Configuration>
^ |
||
{ | ||
static Node encode(const eCAL::Logging::Sinks::UDP::Configuration& config_); | ||
|
||
static bool decode(const Node& node_, eCAL::Logging::Sinks::UDP::Configuration& config_); | ||
}; | ||
|
||
template<> | ||
struct convert<eCAL::Logging::Sinks::Sink> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::Logging::Sinks::Sink" is directly included [misc-include-cleaner] struct convert<eCAL::Logging::Sinks::Sink>
^ |
||
{ | ||
static Node encode(const eCAL::Logging::Sinks::Sink& config_); | ||
|
||
static bool decode(const Node& node_, eCAL::Logging::Sinks::Sink& config_); | ||
}; | ||
|
||
template<> | ||
struct convert<eCAL::Logging::Sinks::Configuration> | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL::Init::Default" is directly included [misc-include-cleaner]
app/rec/rec_server_core/src/rec_server_impl.cpp:21: