19#define PRIORITY_UNSET_ADC_SYSLOG -1
24 while (prioritynames[i].c_name &&
25 strcmp(prioritynames[i].c_name,s.c_str()))
27 if (!prioritynames[i].c_name)
30 return prioritynames[i].c_val;
49 inline static const std::map< const string, const string > plugin_syslog_config_defaults =
50 {{
"PRIORITY",
"info"} };
51 inline static const char *plugin_prefix =
"ADC_SYSLOG_PLUGIN_";
53 const std::vector<string> tags;
57 int config(
string p) {
63 const string get(
const std::map< string, string >& m,
66 auto it = m.find(
field);
70 string en = std::string(env_prefix) +=
field;
71 char *ec = getenv(en.c_str());
73 return plugin_syslog_config_defaults.at(
field);
81 openlog(
"ADC", LOG_PID, LOG_USER);
85 int publish(std::shared_ptr<builder_api> b) {
90 auto str = b->serialize();
91 syslog(priority,
"%s", str.c_str());
95 int config(
const std::map< std::string, std::string >& m) {
96 return config(m, plugin_prefix);
99 int config(
const std::map< std::string, std::string >& m, std::string_view env_prefix) {
100 string p = get(m,
"PRIORITY", env_prefix);
101 return config(std::move(p));
105 return plugin_syslog_config_defaults;
109 std::map <string, string >m;
Publisher plugin interface.
syslog publisher_api implementation. This plugin sends messages to syslog synchronously....
int publish(std::shared_ptr< builder_api > b)
Publish the content of the builder.
string_view version() const
const std::map< const std::string, const std::string > & get_option_defaults()
Look up the settable options and their defaults.
void finalize()
Stop publishing and release any resources held for managing publication.
void pause()
Pause publishing until a call to resume. Duplicate calls are allowed.
int initialize()
Ready the plugin to publish following the configuration options set or defaulted.
int config(const std::map< std::string, std::string > &m, std::string_view env_prefix)
Configure the plugin with the options given and the corresponding environment variables.
void resume()
Resume publishing Duplicate calls are allowed.
int config(const std::map< std::string, std::string > &m)
Configure the plugin with the options given.
std::string_view string_view
int get_priority_from_string(string s)
#define PRIORITY_UNSET_ADC_SYSLOG