15#define PRIORITY_UNSET_ADC_SYSLOG -1
20 while (prioritynames[i].c_name &&
21 strcmp(prioritynames[i].c_name,s.c_str()))
23 if (!prioritynames[i].c_name)
26 return prioritynames[i].c_val;
44 inline static const std::map< const string, const string > plugin_syslog_config_defaults =
45 {{
"PRIORITY",
"info"} };
46 inline static const char *plugin_prefix =
"ADC_SYSLOG_PLUGIN_";
48 const std::vector<string> tags;
52 int config(
string p) {
58 const string get(
const std::map< string, string >& m,
61 auto it = m.find(
field);
65 string en = std::string(env_prefix) +=
field;
66 char *ec = getenv(en.c_str());
68 return plugin_syslog_config_defaults.at(
field);
76 openlog(
"ADC", LOG_PID, LOG_USER);
80 int publish(std::shared_ptr<builder_api> b) {
85 auto str = b->serialize();
86 syslog(priority,
"%s", str.c_str());
90 int config(
const std::map< std::string, std::string >& m) {
91 return config(m, plugin_prefix);
94 int config(
const std::map< std::string, std::string >& m, std::string_view env_prefix) {
95 string p = get(m,
"PRIORITY", env_prefix);
96 return config(std::move(p));
100 return plugin_syslog_config_defaults;
104 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