xref: /NextBSD/sbin/launchd/log.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 #ifndef __LAUNCHD_LOG_H__
2 #define __LAUNCHD_LOG_H__
3 
4 #include <mach/mach.h>
5 #include <sys/types.h>
6 #include <sys/time.h>
7 #include <sys/queue.h>
8 #include <sys/fcntl.h>
9 #include <unistd.h>
10 #include <pthread.h>
11 #include <errno.h>
12 #include <string.h>
13 #include <ctype.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <stdbool.h>
17 #include <syslog.h>
18 
19 extern const char *launchd_username;
20 extern const char *launchd_label;
21 extern mach_port_t launchd_drain_reply_port;
22 extern bool launchd_var_available;
23 extern int64_t launchd_system_start;
24 
25 struct launchd_syslog_attr {
26 	const char *from_name;
27 	const char *about_name;
28 	const char *session_name;
29 	int priority;
30 	uid_t from_uid;
31 	pid_t from_pid;
32 	pid_t about_pid;
33 };
34 
35 /* These constants must not have the high bit set so we can safely mask them
36  * mask them with LOG_CONSOLE.
37  */
38 #define LOG_PERF 0x5252615d
39 #define LOG_APPLEONLY 0x4141504c
40 #ifdef notyet
41 #define LOG_CONSOLE (1 << 31)
42 #endif
43 __attribute__((visibility("default")))
44 __attribute__((used))
45 extern bool
46 _launchd_os_redirect(const char *message);
47 
48 int
49 runtime_setlogmask(int maskpri);
50 
51 void
52 launchd_closelog(void);
53 
54 __attribute__((format(printf, 2, 3)))
55 void
56 launchd_syslog(int pri, const char *message, ...);
57 
58 __attribute__((format(printf, 2, 0)))
59 void
60 launchd_vsyslog(struct launchd_syslog_attr *attr, const char *message, va_list args);
61 
62 void
63 launchd_log_push(void);
64 
65 kern_return_t
66 launchd_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt);
67 
68 kern_return_t
69 launchd_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt);
70 
71 #endif /* __LAUNCHD_LOG_H__ */
72