sys_log.h 1.0 KB

123456789101112131415161718192021
  1. #ifndef __ADAYO_SYS_LOG_H__
  2. #define __ADAYO_SYS_LOG_H__
  3. #include <syslog.h>
  4. #define SYS_LOG_OPEN(TAG) openlog (TAG, LOG_PID, LOG_USER)
  5. #define SYS_LOG_CLOSE() closelog()
  6. #define SYS_LOG_BASE(__pri, fmt, arg...) syslog(__pri ,"[%s,%d] " fmt, __FUNCTION__, __LINE__, ##arg)
  7. #define SLOG_EMERG(fmt, arg...) SYS_LOG_BASE(LOG_EMERG,fmt,##arg) /* system is unusable */
  8. #define SLOG_ALERT(fmt, arg...) SYS_LOG_BASE(LOG_ALERT,fmt,##arg) /* action must be taken immediately */
  9. #define SLOG_CRIT(fmt, arg...) SYS_LOG_BASE(LOG_CRIT,fmt,##arg) /* critical conditions */
  10. #define SLOG_ERR(fmt, arg...) SYS_LOG_BASE(LOG_ERR,fmt,##arg) /* error conditions */
  11. #define SLOG_WARNING(fmt, arg...) SYS_LOG_BASE(LOG_WARNING,fmt,##arg) /* warning conditions */
  12. #define SLOG_NOTICE(fmt, arg...) SYS_LOG_BASE(LOG_NOTICE,fmt,##arg) /* normal but significant condition */
  13. #define SLOG_INFO(fmt, arg...) SYS_LOG_BASE(LOG_INFO,fmt,##arg) /* informational */
  14. #define SLOG_DEBUG(fmt, arg...) SYS_LOG_BASE(LOG_DEBUG,fmt,##arg) /* debug-level messages */
  15. #endif