]>
Commit | Line | Data |
---|---|---|
0a852417 PD |
1 | # -*- coding: utf-8 -*- |
2 | ||
3 | """ | |
4 | Syslog built-in backend. | |
5 | """ | |
6 | ||
7 | __author__ = "Paul Durrant <paul.durrant@citrix.com>" | |
8 | __copyright__ = "Copyright 2016, Citrix Systems Inc." | |
9 | __license__ = "GPL version 2 or (at your option) any later version" | |
10 | ||
11 | __maintainer__ = "Stefan Hajnoczi" | |
12 | __email__ = "stefanha@redhat.com" | |
13 | ||
14 | ||
9d672e29 TDS |
15 | import os.path |
16 | ||
0a852417 PD |
17 | from tracetool import out |
18 | ||
19 | ||
20 | PUBLIC = True | |
21 | ||
22 | ||
80dd5c49 | 23 | def generate_h_begin(events, group): |
0a852417 | 24 | out('#include <syslog.h>', |
0a852417 PD |
25 | '') |
26 | ||
27 | ||
80dd5c49 | 28 | def generate_h(event, group): |
0a852417 PD |
29 | argnames = ", ".join(event.args.names()) |
30 | if len(event.args) > 0: | |
31 | argnames = ", " + argnames | |
32 | ||
33 | if "vcpu" in event.properties: | |
34 | # already checked on the generic format code | |
35 | cond = "true" | |
36 | else: | |
37 | cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) | |
38 | ||
1ff7b531 | 39 | out(' if (%(cond)s) {', |
7fb48c0e | 40 | '#line %(event_lineno)d "%(event_filename)s"', |
1ff7b531 | 41 | ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', |
7fb48c0e | 42 | '#line %(out_next_lineno)d "%(out_filename)s"', |
1ff7b531 | 43 | ' }', |
0a852417 | 44 | cond=cond, |
7fb48c0e | 45 | event_lineno=event.lineno, |
9d672e29 | 46 | event_filename=os.path.relpath(event.filename), |
0a852417 PD |
47 | name=event.name, |
48 | fmt=event.fmt.rstrip("\n"), | |
49 | argnames=argnames) | |
3932ef3f SH |
50 | |
51 | ||
52 | def generate_h_backend_dstate(event, group): | |
53 | out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\', | |
54 | event_id="TRACE_" + event.name.upper()) |