Skip to content

Commit ac348da

Browse files
authored
Merge pull request #4374 from bosilca/topic/osx_syslog
Topic/osx syslog
2 parents 0721d93 + 8f32b34 commit ac348da

File tree

6 files changed

+84
-11
lines changed

6 files changed

+84
-11
lines changed

opal/mca/base/mca_base_open.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2008 The University of Tennessee and The University
6+
* Copyright (c) 2004-2017 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -176,8 +176,10 @@ static void set_defaults(opal_output_stream_t *lds)
176176
/* Load up defaults */
177177

178178
OBJ_CONSTRUCT(lds, opal_output_stream_t);
179+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
179180
lds->lds_syslog_priority = LOG_INFO;
180181
lds->lds_syslog_ident = "ompi";
182+
#endif
181183
lds->lds_want_stderr = true;
182184
}
183185

@@ -207,10 +209,15 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
207209
}
208210

209211
if (0 == strcasecmp(ptr, "syslog")) {
212+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
210213
lds->lds_want_syslog = true;
211214
have_output = true;
215+
#else
216+
opal_output(0, "syslog support requested but not available on this system");
217+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
212218
}
213219
else if (strncasecmp(ptr, "syslogpri:", 10) == 0) {
220+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
214221
lds->lds_want_syslog = true;
215222
have_output = true;
216223
if (strcasecmp(ptr + 10, "notice") == 0)
@@ -219,9 +226,16 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
219226
lds->lds_syslog_priority = LOG_INFO;
220227
else if (strcasecmp(ptr + 10, "DEBUG") == 0)
221228
lds->lds_syslog_priority = LOG_DEBUG;
229+
#else
230+
opal_output(0, "syslog support requested but not available on this system");
231+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
222232
} else if (strncasecmp(ptr, "syslogid:", 9) == 0) {
233+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
223234
lds->lds_want_syslog = true;
224235
lds->lds_syslog_ident = ptr + 9;
236+
#else
237+
opal_output(0, "syslog support requested but not available on this system");
238+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
225239
}
226240

227241
else if (strcasecmp(ptr, "stdout") == 0) {

opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_open.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2008 The University of Tennessee and The University
6+
* Copyright (c) 2004-2017 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -171,7 +171,9 @@ static void set_defaults(pmix_output_stream_t *lds)
171171
/* Load up defaults */
172172

173173
PMIX_CONSTRUCT(lds, pmix_output_stream_t);
174+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
174175
lds->lds_syslog_priority = LOG_INFO;
176+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
175177
lds->lds_syslog_ident = "ompi";
176178
lds->lds_want_stderr = true;
177179
}
@@ -202,10 +204,15 @@ static void parse_verbose(char *e, pmix_output_stream_t *lds)
202204
}
203205

204206
if (0 == strcasecmp(ptr, "syslog")) {
207+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
205208
lds->lds_want_syslog = true;
206209
have_output = true;
210+
#else
211+
pmix_output(0, "syslog support requested but not available on this system");
212+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
207213
}
208214
else if (strncasecmp(ptr, "syslogpri:", 10) == 0) {
215+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
209216
lds->lds_want_syslog = true;
210217
have_output = true;
211218
if (strcasecmp(ptr + 10, "notice") == 0)
@@ -214,9 +221,16 @@ static void parse_verbose(char *e, pmix_output_stream_t *lds)
214221
lds->lds_syslog_priority = LOG_INFO;
215222
else if (strcasecmp(ptr + 10, "DEBUG") == 0)
216223
lds->lds_syslog_priority = LOG_DEBUG;
224+
#else
225+
pmix_output(0, "syslog support requested but not available on this system");
226+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
217227
} else if (strncasecmp(ptr, "syslogid:", 9) == 0) {
228+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
218229
lds->lds_want_syslog = true;
219230
lds->lds_syslog_ident = ptr + 9;
231+
#else
232+
pmix_output(0, "syslog support requested but not available on this system");
233+
#endif /* defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H) */
220234
}
221235

222236
else if (strcasecmp(ptr, "stdout") == 0) {

opal/mca/pmix/pmix3x/pmix/src/util/output.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2008 The University of Tennessee and The University
5+
* Copyright (c) 2004-2017 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@@ -143,6 +143,7 @@ bool pmix_output_init(void)
143143
}
144144
}
145145
str = getenv("PMIX_OUTPUT_SYSLOG_PRI");
146+
#ifdef HAVE_SYSLOG_H
146147
if (NULL != str) {
147148
if (0 == strcasecmp(str, "info")) {
148149
pmix_output_redirected_syslog_pri = LOG_INFO;
@@ -156,6 +157,7 @@ bool pmix_output_init(void)
156157
} else {
157158
pmix_output_redirected_syslog_pri = LOG_ERR;
158159
}
160+
#endif
159161

160162
str = getenv("PMIX_OUTPUT_SYSLOG_IDENT");
161163
if (NULL != str) {

opal/util/output.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2008 The University of Tennessee and The University
6+
* Copyright (c) 2004-2017 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@@ -147,6 +147,7 @@ bool opal_output_init(void)
147147
}
148148
}
149149
str = getenv("OPAL_OUTPUT_SYSLOG_PRI");
150+
#ifdef HAVE_SYSLOG_H
150151
if (NULL != str) {
151152
if (0 == strcasecmp(str, "info")) {
152153
opal_output_redirected_syslog_pri = LOG_INFO;
@@ -160,7 +161,7 @@ bool opal_output_init(void)
160161
} else {
161162
opal_output_redirected_syslog_pri = LOG_ERR;
162163
}
163-
164+
#endif /* HAVE_SYSLOG_H */
164165
str = getenv("OPAL_OUTPUT_SYSLOG_IDENT");
165166
if (NULL != str) {
166167
redirect_syslog_ident = strdup(str);
@@ -349,7 +350,7 @@ void opal_output_close(int output_id)
349350
}
350351
}
351352

352-
#if defined(HAVE_SYSLOG)
353+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
353354
if (i >= OPAL_OUTPUT_MAX_STREAMS && syslog_opened) {
354355
closelog();
355356
}
@@ -612,7 +613,7 @@ static int do_open(int output_id, opal_output_stream_t * lds)
612613
info[i].ldi_verbose_level = lds->lds_verbose_level;
613614

614615
#if USE_SYSLOG
615-
#if defined(HAVE_SYSLOG)
616+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
616617
if (opal_output_redirected_to_syslog) {
617618
info[i].ldi_syslog = true;
618619
info[i].ldi_syslog_priority = opal_output_redirected_syslog_pri;
@@ -629,7 +630,7 @@ static int do_open(int output_id, opal_output_stream_t * lds)
629630
info[i].ldi_syslog = lds->lds_want_syslog;
630631
if (lds->lds_want_syslog) {
631632

632-
#if defined(HAVE_SYSLOG)
633+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
633634
if (NULL != lds->lds_syslog_ident) {
634635
info[i].ldi_syslog_ident = strdup(lds->lds_syslog_ident);
635636
openlog(lds->lds_syslog_ident, LOG_PID, LOG_USER);
@@ -642,7 +643,7 @@ static int do_open(int output_id, opal_output_stream_t * lds)
642643
info[i].ldi_syslog_priority = lds->lds_syslog_priority;
643644
}
644645

645-
#if defined(HAVE_SYSLOG)
646+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
646647
}
647648
#endif
648649

@@ -951,7 +952,7 @@ static int output(int output_id, const char *format, va_list arglist)
951952
}
952953

953954
/* Syslog output -- does not use the newline-appended string */
954-
#if defined(HAVE_SYSLOG)
955+
#if defined(HAVE_SYSLOG) && defined(HAVE_SYSLOG_H)
955956
if (ldi->ldi_syslog) {
956957
syslog(ldi->ldi_syslog_priority, "%s", str);
957958
}

orte/mca/notifier/notifier.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2017 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -68,6 +68,7 @@ ORTE_DECLSPEC extern int orte_notifier_debug_output;
6868

6969
/* Severities */
7070
typedef enum {
71+
#ifdef HAVE_SYSLOG_H
7172
ORTE_NOTIFIER_EMERG = LOG_EMERG,
7273
ORTE_NOTIFIER_ALERT = LOG_ALERT,
7374
ORTE_NOTIFIER_CRIT = LOG_CRIT,
@@ -76,6 +77,16 @@ typedef enum {
7677
ORTE_NOTIFIER_NOTICE = LOG_NOTICE,
7778
ORTE_NOTIFIER_INFO = LOG_INFO,
7879
ORTE_NOTIFIER_DEBUG = LOG_DEBUG
80+
#else
81+
ORTE_NOTIFIER_EMERG,
82+
ORTE_NOTIFIER_ALERT,
83+
ORTE_NOTIFIER_CRIT,
84+
ORTE_NOTIFIER_ERROR,
85+
ORTE_NOTIFIER_WARN,
86+
ORTE_NOTIFIER_NOTICE,
87+
ORTE_NOTIFIER_INFO,
88+
ORTE_NOTIFIER_DEBUG
89+
#endif
7990
} orte_notifier_severity_t;
8091

8192
typedef struct {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2017 Cisco Systems, Inc. All rights reserved.
4+
# $COPYRIGHT$
5+
#
6+
# Additional copyrights may follow
7+
#
8+
# $HEADER$
9+
#
10+
11+
# MCA_notifier_syslog_CONFIG([action-if-found], [action-if-not-found])
12+
# -----------------------------------------------------------
13+
AC_DEFUN([MCA_orte_notifier_syslog_CONFIG], [
14+
AC_CONFIG_FILES([orte/mca/notifier/syslog/Makefile])
15+
16+
OPAL_VAR_SCOPE_PUSH([orte_notifier_syslog_happy])
17+
18+
# Per https://github.com/open-mpi/ompi/issues/4373 and
19+
# https://github.com/open-mpi/ompi/pull/4374, we need to check
20+
# that syslog.h is compilable. If syslog.h is not compilable,
21+
# disable this component.
22+
AC_CHECK_HEADER([syslog.h],
23+
[orte_notifier_syslog_happy=1],
24+
[orte_notifier_syslog_happy=0])
25+
26+
AS_IF([test $orte_notifier_syslog_happy -eq 1],
27+
[$1],
28+
[$2])
29+
30+
OPAL_VAR_SCOPE_POP
31+
])dnl

0 commit comments

Comments
 (0)