1 /* 2 * Copyright (c) 2015-2024 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_SUBSYSTEM "com.apple.xnu.oslog" 33 #define OS_LOG_MAX_SIZE_ORDER 10 // Maximum log size order (1024 bytes) 34 35 __BEGIN_DECLS 36 37 /*! 38 * @function os_log_with_args 39 * 40 * @abstract 41 * os_log variant that supports va_list args. 42 * 43 * @discussion 44 * os_log variant that supports va_list args. This SPI should only be used 45 * to shim legacy logging systems through os_log. 46 * 47 * @param oslog 48 * Pass OS_LOG_DEFAULT or a log object previously created with os_log_create. 49 * 50 * @param type 51 * Pass one of the following message types. 52 * OS_LOG_TYPE_DEFAULT 53 * OS_LOG_TYPE_DEBUG 54 * OS_LOG_TYPE_INFO 55 * OS_LOG_TYPE_ERROR 56 * OS_LOG_TYPE_FAULT 57 * 58 * @param format 59 * A format string to generate a human-readable log message when the log 60 * line is decoded. Supports all standard printf types in addition to %@ 61 * and %m (objects and errno respectively). 62 * 63 * @param args 64 * A va_list containing the values for the format string. 65 * 66 * @param ret_addr 67 * Pass the __builtin_return_address(0) of the function that created the 68 * va_list from variadic arguments. The caller must be the same binary 69 * that generated the message and provided the format string. 70 */ 71 void 72 os_log_with_args(os_log_t oslog, os_log_type_t type, const char *format, va_list args, void *ret_addr) 73 __osloglike(3, 0); 74 75 /* 76 * A private interface allowing to emit already encoded log messages. 77 */ 78 bool os_log_encoded_metadata(firehose_tracepoint_id_u, uint64_t, const void *, size_t); 79 bool os_log_encoded_signpost(firehose_stream_t, firehose_tracepoint_id_u, uint64_t, const void *, size_t, size_t); 80 bool os_log_encoded_log(firehose_stream_t, firehose_tracepoint_id_u, uint64_t, const void *, size_t, size_t); 81 82 __END_DECLS 83 84 #endif // __os_log_private_h 85