Various modules solving daily C developer tasks
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.

59 lines
1.3 KiB

  1. /******************************************************************************
  2. *
  3. * Copyright (c) 2017-2019 by Löwenware Ltd
  4. * Please, refer LICENSE file for legal information
  5. *
  6. ******************************************************************************/
  7. /**
  8. * @file log.h
  9. * @author Ilja Kartašov <ik@lowenware.com>
  10. * @brief cStuff log module header file
  11. *
  12. * @see https://lowenware.com/cStuff/
  13. */
  14. #ifndef CSTUFF_LOG_H_557ADEFE_2BE8_4B9B_A894_F08FF64008EF
  15. #define CSTUFF_LOG_H_557ADEFE_2BE8_4B9B_A894_F08FF64008EF
  16. #include <stdio.h>
  17. #include <stdarg.h>
  18. #include <stdint.h>
  19. #include "retcode.h"
  20. #define CSTUFF_LOG_OFF (0)
  21. #define CSTUFF_LOG_ERROR (1<<0)
  22. #define CSTUFF_LOG_ALERT (1<<1)
  23. #define CSTUFF_LOG_STATE (1<<2)
  24. #define CSTUFF_LOG_DEBUG (1<<3)
  25. #define CSTUFF_LOG_ALL (0xFF)
  26. struct cstuff_log {
  27. FILE *target;
  28. uint8_t level;
  29. };
  30. typedef struct cstuff_log * CStuffLog;
  31. void
  32. cstuff_log_init(CStuffLog self, int level);
  33. void
  34. cstuff_log_release(CStuffLog self);
  35. CStuffRetcode
  36. cstuff_log_set_file(CStuffLog self, const char *filename);
  37. int
  38. cstuff_log_printf(CStuffLog self, int level, const char *format, ...);
  39. int
  40. cstuff_log_vprintf(CStuffLog self, int level, const char *format, va_list vl);
  41. #endif /* !CSTUFF_LOG_H */