logger.h 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <syslog.h>
  4. #ifndef LOGGER_H
  5. #define LOGGER_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. // do not collide with constants defined in syslog.h
  10. enum LogLevel { ZLOG_FATAL, ZLOG_ERROR, ZLOG_WARN, ZLOG_INFO, ZLOG_DEBUG, ZLOG_TRACE,
  11. ZNUM_LOGLEVELS };
  12. int log_fatal(const char *loggerName, const char *logMessage, ...) __attribute__((noreturn));
  13. int log_error(const char *loggerName, const char *logMessage, ...);
  14. int log_warn(const char *loggerName, const char *logMessage, ...);
  15. int log_info(const char *loggerName, const char *logMessage, ...);
  16. int log_debug(const char *loggerName, const char *logMessage, ...);
  17. int log_trace(const char *loggerName, const char *logMessage, ...);
  18. int log_init(FILE *stream, enum LogLevel level,
  19. int syslog_enabled, const char *syslog_app);
  20. void check_and_log_file_error(FILE *file, const char*name);
  21. size_t dstrftime(char *, size_t, const char *, double);
  22. double now();
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26. #endif // _LOGGER_H