]> git.cameronkatri.com Git - apple_cmds.git/blob - network_cmds/rtadvd.tproj/rtadvd_logging.c
file_cmds: Fix .PATH
[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 <os/log_private.h>
13
14 #define kRtadvdLoggerID "com.apple.rtadvd"
15 static os_log_t rtadvdLogger = NULL; /* Handle for Logger */
16
17 static boolean_t rtadvd_logger_create(void);
18
19 static boolean_t
20 rtadvd_logger_create(void)
21 {
22 assert(rtadvdLogger == NULL);
23 rtadvdLogger = os_log_create(kRtadvdLoggerID, "daemon");
24
25 if (rtadvdLogger == NULL) {
26 os_log_error(OS_LOG_DEFAULT, "Couldn't create os log object");
27 }
28
29 return (rtadvdLogger != NULL);
30 }
31
32 void
33 rtadvdLog(int level, const char *format, ...)
34 {
35 va_list args;
36
37 if (rtadvdLogger == NULL && !rtadvd_logger_create()) {
38 return;
39 }
40
41 va_start(args, format);
42 os_log_with_args(rtadvdLogger, level, format, args, __builtin_return_address(0));
43 va_end(args);
44 return;
45 }