forked from syscl/maclog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaclog.h
More file actions
executable file
·119 lines (108 loc) · 2.55 KB
/
Copy pathmaclog.h
File metadata and controls
executable file
·119 lines (108 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//
// maclog.h
// maclog
//
// Created by lighting on 1/7/17.
// Copyright (c) 2017 syscl. All rights reserved.
//
// This work is licensed under the Creative Commons Attribution-NonCommercial
// 4.0 Unported License => http://creativecommons.org/licenses/by-nc/4.0
//
#define PROGRAM_VER 1.6
#include <Carbon/Carbon.h>
//
// for open(...)
//
#include <fcntl.h>
#include <sys/stat.h>
//
// for sysctl(...)
//
#include <sys/sysctl.h>
//
// for time(...)
//
#include <time.h>
#include <string.h>
//
// for access to old ASL logging system
//
#include <asl.h>
//
// for getopt_long(...)
// more info: http://man7.org/linux/man-pages/man3/getopt.3.html
//
#include <getopt.h>
//
// Power Management's ASL keys
// from: https://opensource.apple.com/source/PowerManagement/PowerManagement-637.50.9/common/CommonLib.h.auto.html
// TODO: Find a way to include PowerManagement CommonLib.h, so we don't have to define this here.
//
#define kPMASLDomainKey "com.apple.iokit.domain"
#define kPMASLStorePath "/var/log/powermanagement"
#define kPMASLDomainPMWake "Wake"
#define kPMASLDomainPMSleep "Sleep"
#define kPMASLDomainPMDarkWake "DarkWake"
//
// flags for different log argv
//
#define showLogArgv 0
#define streamLogArgv 1
//
// file permission, we use 0644 for both convince and safety reason
//
#define PERMS 0644
//
// get default log name and path
//
#define gLogPath "/tmp/system.log"
//
// argument flags
//
#define shortOptions "bdf:hsSvw"
struct option longOptions[] = {
{"boot", no_argument, NULL, 'b'},
{"darkWake", no_argument, NULL, 'd'},
{"filter", required_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"sleep", no_argument, NULL, 's'},
{"stream", no_argument, NULL, 'S'},
{"version", no_argument, NULL, 'v'},
{"wake", no_argument, NULL, 'w'},
{0, 0, 0, 0 },
};
//
// constants for gLogArgs, for making them easy to change and increase readability
//
#define gLogCommand 1
#define gLogTime 9
#define gLogFilter 3
//
// filter
//
#define predicate "(process == \"kernel\" OR eventMessage CONTAINS[c] \"kernel\")"
#define filterConcat " AND "
//
// get log argv
//
char *gLogArgs[] = {
"log",
NULL,
"--predicate",
predicate,
"--style",
"syslog",
"--source",
NULL,
NULL,
NULL,
NULL
};
//
// get open argv
//
char *gOpenf[] = {
"open",
gLogPath,
NULL
};