X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsystemd%2Fsd-journal.h;h=f27e461b036fc83f6acd0364db6d340d38b59de7;hp=5a2dab15694461403dd2a1ca5b48bae91e16e0d9;hb=b070e7f3c9ed680c821bd89d42506695f2438506;hpb=1fa80181aecd4b9db513f16c136157a4546686d3 diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h index 5a2dab156..f27e461b0 100644 --- a/src/systemd/sd-journal.h +++ b/src/systemd/sd-journal.h @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -34,13 +35,30 @@ extern "C" { #endif /* Write to daemon */ - int sd_journal_print(int piority, const char *format, ...) __attribute__ ((format (printf, 2, 3))); int sd_journal_printv(int priority, const char *format, va_list ap); - int sd_journal_send(const char *format, ...) __attribute__((sentinel)); int sd_journal_sendv(const struct iovec *iov, int n); +/* Used by the macros below */ +int sd_journal_print_with_location(int priority, const char *file, const char *line, const char *func, const char *format, ...) __attribute__ ((format (printf, 5, 6))); +int sd_journal_printv_with_location(int priority, const char *file, const char *line, const char *func, const char *format, va_list ap); +int sd_journal_send_with_location(const char *file, const char *line, const char *func, const char *format, ...) __attribute__((sentinel)); +int sd_journal_sendv_with_location(const char *file, const char *line, const char *func, const struct iovec *iov, int n); + +/* implicitly add code location to messages sent, if this is enabled */ +#ifndef SD_JOURNAL_SUPPRESS_LOCATION + +#define _sd_XSTRINGIFY(x) #x +#define _sd_STRINGIFY(x) _sd_XSTRINGIFY(x) + +#define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _sd_STRINGIFY(__LINE__), __func__, __VA_ARGS__) +#define sd_journal_printv(priority, format, ap) sd_journal_printv_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _sd_STRINGIFY(__LINE__), __func__, format, ap) +#define sd_journal_send(...) sd_journal_send_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_STRINGIFY(__LINE__), __func__, __VA_ARGS__) +#define sd_journal_sendv(iovec, n) sd_journal_sendv_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_STRINGIFY(__LINE__), __func__, iovec, n) + +#endif + int sd_journal_stream_fd(const char *identifier, int priority, int level_prefix); /* Browse journal stream */