Discord library in plain C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

log.h 1.1KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Copyright (c) 2017 rxi
  3. *
  4. * This library is free software; you can redistribute it and/or modify it
  5. * under the terms of the MIT license. See `log.c` for details.
  6. */
  7. #ifndef LOG_H
  8. #define LOG_H
  9. #include <stdio.h>
  10. #include <stdarg.h>
  11. #define LOG_VERSION "0.1.0"
  12. typedef void (*log_LockFn)(void *udata, int lock);
  13. enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
  14. #define log_trace(...) log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
  15. #define log_debug(...) log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
  16. #define log_info(...) log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
  17. #define log_warn(...) log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
  18. #define log_error(...) log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
  19. #define log_fatal(...) log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
  20. void log_set_udata(void *udata);
  21. void log_set_lock(log_LockFn fn);
  22. void log_set_fp(FILE *fp);
  23. void log_set_level(int level);
  24. void log_set_quiet(int enable);
  25. void log_log(int level, const char *file, int line, const char *fmt, ...);
  26. #endif