-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.m
82 lines (54 loc) · 1.53 KB
/
main.m
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
//
// main.m
//
#import <Foundation/Foundation.h>
#import "lcl.h"
#undef ql_component
#define ql_component lcl_cMainC1
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// show the name of the log file
printf("Log messages are written to %s. You can open Console.app to view the log file, it's listed in the ~/Library/Logs section.\n", [[LCLLogFile path] UTF8String]);
// enable logging for all components up to level Debug
lcl_configure_by_name("*", lcl_vTrace);
//
// logging with lcl_log macros:
//
// log
lcl_log(lcl_cMain, lcl_vInfo, @"log message %d", 1);
// do something
printf("hello world\n");
// log again
lcl_log(lcl_cMain, lcl_vInfo, @"log message %d", 2);
//
// logging with lcl_log_if macros:
//
int p = 0;
// log
lcl_log_if(lcl_cMain, lcl_vInfo, p > 0, @"log message %d", 1);
// change p
p = 1;
// log
lcl_log_if(lcl_cMain, lcl_vInfo, p > 0, @"log message %d", 1);
//
// logging with qlog macros:
//
// log
qlinfo(@"info message %d using qlog", 1);
// simple trace log without message
qltrace();
// log again
qlinfo(@"info message %d using qlog", 2);
//
// logging with qlog_if macros:
//
int q = 0;
// log
qlerror_if(q, @"error!");
// change q
q = 1;
// log
qlerror_if(q, @"error!");
[pool release];
return 0;
}