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