This source file includes following definitions.
- syslog_register
- component_query
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include "pmix_config.h"
15 #include "pmix_common.h"
16
17 #ifdef HAVE_SYSLOG_H
18 #include <syslog.h>
19 #endif
20
21 #include "src/util/show_help.h"
22 #include "plog_syslog.h"
23
24
25 static pmix_status_t component_query(pmix_mca_base_module_t **module,
26 int *priority);
27 static pmix_status_t syslog_register(void);
28
29
30
31
32 pmix_plog_syslog_component_t mca_plog_syslog_component = {
33 .super = {
34 .base = {
35 PMIX_PLOG_BASE_VERSION_1_0_0,
36
37 .pmix_mca_component_name = "syslog",
38 PMIX_MCA_BASE_MAKE_VERSION(component, PMIX_MAJOR_VERSION, PMIX_MINOR_VERSION,
39 PMIX_RELEASE_VERSION),
40 .pmix_mca_query_component = component_query,
41 .pmix_mca_register_component_params = syslog_register,
42 },
43 .data = {
44
45 PMIX_MCA_BASE_METADATA_PARAM_CHECKPOINT
46 },
47 },
48 .console = false,
49 .level = LOG_ERR,
50 .facility = LOG_USER
51 };
52
53 static char *level = "info";
54 static char *facility = "user";
55
56 static pmix_status_t syslog_register(void)
57 {
58 pmix_status_t rc = PMIX_SUCCESS;
59
60 (void) pmix_mca_base_component_var_register(&mca_plog_syslog_component.super.base, "console",
61 "Write directly to system console if there is an error while sending to system logger",
62 PMIX_MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
63 PMIX_INFO_LVL_2,
64 PMIX_MCA_BASE_VAR_SCOPE_READONLY,
65 &mca_plog_syslog_component.console);
66
67 (void) pmix_mca_base_component_var_register(&mca_plog_syslog_component.super.base, "level",
68 "Default syslog logging level (err, alert, crit, emerg, warning, notice, info[default], or debug)",
69 PMIX_MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
70 PMIX_INFO_LVL_2,
71 PMIX_MCA_BASE_VAR_SCOPE_READONLY,
72 &level);
73 if (0 == strncasecmp(level, "err", 3)) {
74 mca_plog_syslog_component.level = LOG_ERR;
75 } else if (0 == strcasecmp(level, "alert")) {
76 mca_plog_syslog_component.level = LOG_ALERT;
77 } else if (0 == strncasecmp(level, "crit", 4)) {
78 mca_plog_syslog_component.level = LOG_CRIT;
79 } else if (0 == strncasecmp(level, "emerg", 5)) {
80 mca_plog_syslog_component.level = LOG_EMERG;
81 } else if (0 == strncasecmp(level, "warn", 4)) {
82 mca_plog_syslog_component.level = LOG_WARNING;
83 } else if (0 == strncasecmp(level, "not", 3)) {
84 mca_plog_syslog_component.level = LOG_NOTICE;
85 } else if (0 == strcasecmp(level, "info")) {
86 mca_plog_syslog_component.level = LOG_INFO;
87 } else if (0 == strcasecmp(level, "debug") || 0 == strcasecmp(level, "dbg")) {
88 mca_plog_syslog_component.level = LOG_DEBUG;
89 } else {
90 pmix_show_help("help-pmix-plog.txt", "syslog:unrec-level", true, level);
91 rc = PMIX_ERR_NOT_SUPPORTED;
92 }
93
94 (void) pmix_mca_base_component_var_register(&mca_plog_syslog_component.super.base, "facility",
95 "Specify what type of program is logging the message "
96 "(only \"auth\", \"priv\", \"daemon\", and \"user\" are supported)",
97 PMIX_MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
98 PMIX_INFO_LVL_2,
99 PMIX_MCA_BASE_VAR_SCOPE_READONLY,
100 &facility);
101 if (0 == strncasecmp(facility, "auth", 4)) {
102 mca_plog_syslog_component.facility = LOG_AUTH;
103 } else if (0 == strncasecmp(facility, "priv", 4)) {
104 mca_plog_syslog_component.facility = LOG_AUTHPRIV;
105 } else if (0 == strcasecmp(facility, "daemon")) {
106 mca_plog_syslog_component.facility = LOG_DAEMON;
107 } else if (0 == strcasecmp(facility, "user")) {
108 mca_plog_syslog_component.facility = LOG_USER;
109 } else {
110 pmix_show_help("help-pmix-plog.txt", "syslog:unrec-facility", true, facility);
111 rc = PMIX_ERR_NOT_SUPPORTED;
112 }
113
114 return rc;
115 }
116
117
118 static pmix_status_t component_query(pmix_mca_base_module_t **module,
119 int *priority)
120 {
121 *priority = 10;
122 *module = (pmix_mca_base_module_t *)&pmix_plog_syslog_module;
123 return PMIX_SUCCESS;
124 }