BLog.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @file BLog.c
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #include <stdio.h>
  23. #include "BLog.h"
  24. struct _BLog_channel blog_channel_list[] = {
  25. #include <generated/blog_channels_list.h>
  26. };
  27. struct _BLog_global blog_global = {
  28. #ifndef NDEBUG
  29. .initialized = 0,
  30. #endif
  31. };
  32. static char *level_names[] = {
  33. [BLOG_ERROR] = "ERROR",
  34. [BLOG_WARNING] = "WARNING",
  35. [BLOG_NOTICE] = "NOTICE",
  36. [BLOG_INFO] = "INFO",
  37. [BLOG_DEBUG] = "DEBUG",
  38. };
  39. static void stdout_log (int channel, int level, const char *msg)
  40. {
  41. printf("%s(%s): %s\n", level_names[level], blog_global.channels[channel].name, msg);
  42. }
  43. static void stdout_free (void)
  44. {
  45. }
  46. void BLog_InitStdout (void)
  47. {
  48. BLog_Init(stdout_log, stdout_free);
  49. }