2
0

syslog.py 1.4 KB

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