]> git.cameronkatri.com Git - apple_cmds.git/blob - network_cmds/rtadvd.tproj/rtadvd_logging.c
file_cmds: gzip: Fix BINDIR
[apple_cmds.git] / network_cmds / rtadvd.tproj / rtadvd_logging.c
1 /*
2 * Copyright (c) 2019 Apple Inc. All rights reserved.
3 *
4 * This document is the property of Apple Inc.
5 * It is considered confidential and proprietary.
6 *
7 * This document may not be reproduced or transmitted in any form,
8 * in whole or in part, without the express written permission of
9 * Apple Inc.
10 */
11 #include <assert.h>
12 #include <stdarg.h>
13 #include <os/log_private.h>
14
15 #define kRtadvdLoggerID "com.apple.rtadvd"
16 static os_log_t rtadvdLogger = NULL; /* Handle for Logger */
17
18 static boolean_t rtadvd_logger_create(void);
19
20 static boolean_t
21 rtadvd_logger_create(void)
22 {
23 assert(rtadvdLogger == NULL);
24 rtadvdLogger = os_log_create(kRtadvdLoggerID, "daemon");
25
26 if (rtadvdLogger == NULL) {
27 os_log_error(OS_LOG_DEFAULT, "Couldn't create os log object");
28 }
29
30 return (rtadvdLogger != NULL);
31 }
32
33 void
34 rtadvdLog(int level, const char *format, ...)
35 {
36 va_list args;
37
38 if (rtadvdLogger == NULL && !rtadvd_logger_create()) {
39 return;
40 }
41
42 va_start(args, format);
43 os_log_with_args(rtadvdLogger, level, format, args, __builtin_return_address(0));
44 va_end(args);
45 return;
46 }