1/*
2 * Copyright (c) 2015-2022 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef __os_log_private_h
25#define __os_log_private_h
26
27#include <os/log.h>
28#include <firehose/tracepoint_private.h>
29#include <sys/queue.h>
30
31#define OS_LOG_XNU_SUBSYSTEM "com.apple.xnu"
32#define OS_LOG_MAX_SIZE_ORDER 10 // Maximum log size order (1024 bytes)
33
34__BEGIN_DECLS
35
36/*!
37 * @function os_log_with_args
38 *
39 * @abstract
40 * os_log variant that supports va_list args.
41 *
42 * @discussion
43 * os_log variant that supports va_list args. This SPI should only be used
44 * to shim legacy logging systems through os_log.
45 *
46 * @param oslog
47 * Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
48 *
49 * @param type
50 * Pass one of the following message types.
51 * OS_LOG_TYPE_DEFAULT
52 * OS_LOG_TYPE_DEBUG
53 * OS_LOG_TYPE_INFO
54 * OS_LOG_TYPE_ERROR
55 * OS_LOG_TYPE_FAULT
56 *
57 * @param format
58 * A format string to generate a human-readable log message when the log
59 * line is decoded. Supports all standard printf types in addition to %@
60 * and %m (objects and errno respectively).
61 *
62 * @param args
63 * A va_list containing the values for the format string.
64 *
65 * @param ret_addr
66 * Pass the __builtin_return_address(0) of the function that created the
67 * va_list from variadic arguments. The caller must be the same binary
68 * that generated the message and provided the format string.
69 */
70void
71os_log_with_args(os_log_t oslog, os_log_type_t type, const char *format, va_list args, void *ret_addr)
72__osloglike(3, 0);
73
74/*
75 * A private interface allowing to emit already encoded log messages.
76 */
77bool os_log_encoded_metadata(firehose_tracepoint_id_u, uint64_t, const void *, size_t);
78bool os_log_encoded_signpost(firehose_tracepoint_id_u, uint64_t, const void *, size_t, size_t);
79bool os_log_encoded_log(firehose_tracepoint_id_u, uint64_t, const void *, size_t, size_t);
80
81__END_DECLS
82
83#endif // __os_log_private_h
84