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.

103 lines
2.1 KiB

  1. /*
  2. ISC License
  3. Copyright (c) 2023, Antonio SJ Musumeci <trapexit@spawn.link>
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted, provided that the above
  6. copyright notice and this permission notice appear in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. */
  15. #include <stdarg.h>
  16. #include <syslog.h>
  17. #include <stdbool.h>
  18. void
  19. syslog_open()
  20. {
  21. const char *ident = "mergerfs";
  22. const int option = (LOG_CONS|LOG_PID);
  23. const int facility = LOG_USER;
  24. openlog(ident,option,facility);
  25. }
  26. void
  27. syslog_close()
  28. {
  29. closelog();
  30. }
  31. static
  32. void
  33. syslog_vlog(const int priority_,
  34. const char *format_,
  35. va_list valist_)
  36. {
  37. vsyslog(priority_,format_,valist_);
  38. }
  39. void
  40. syslog_log(const int priority_,
  41. const char *format_,
  42. ...)
  43. {
  44. va_list valist;
  45. va_start(valist,format_);
  46. syslog_vlog(priority_,format_,valist);
  47. va_end(valist);
  48. }
  49. void
  50. syslog_info(const char *format_,
  51. ...)
  52. {
  53. va_list valist;
  54. va_start(valist,format_);
  55. syslog_vlog(LOG_INFO,format_,valist);
  56. va_end(valist);
  57. }
  58. void
  59. syslog_notice(const char *format_,
  60. ...)
  61. {
  62. va_list valist;
  63. va_start(valist,format_);
  64. syslog_vlog(LOG_NOTICE,format_,valist);
  65. va_end(valist);
  66. }
  67. void
  68. syslog_warning(const char *format_,
  69. ...)
  70. {
  71. va_list valist;
  72. va_start(valist,format_);
  73. syslog_vlog(LOG_WARNING,format_,valist);
  74. va_end(valist);
  75. }
  76. void
  77. syslog_error(const char *format_,
  78. ...)
  79. {
  80. va_list valist;
  81. va_start(valist,format_);
  82. syslog_vlog(LOG_ERR,format_,valist);
  83. va_end(valist);
  84. }