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.

110 lines
3.9 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /******************************************************************
  2. * $Id: nanohttp-logging.h,v 1.1 2006/07/09 16:22:52 snowdrop Exp $
  3. *
  4. * CSOAP Project: A http client/server library in C
  5. * Copyright (C) 2003-2006 Ferhat Ayaz
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. *
  22. * Email: hero@persua.de
  23. ******************************************************************/
  24. #ifndef __nanohttp_logging_h
  25. #define __nanohttp_logging_h
  26. #define NHTTP_ARG_LOGFILE "-NHTTPlog"
  27. #define NHTTP_ARG_LOGLEVEL "-NHTTPloglevel"
  28. /* logging stuff */
  29. typedef enum log_level
  30. {
  31. HLOG_VERBOSE,
  32. HLOG_DEBUG,
  33. HLOG_INFO,
  34. HLOG_WARN,
  35. HLOG_ERROR,
  36. HLOG_FATAL
  37. } log_level_t;
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. extern log_level_t hlog_set_level(log_level_t level);
  42. extern log_level_t hlog_get_level(void);
  43. extern void hlog_set_file(const char *filename);
  44. extern char *hlog_get_file();
  45. #ifdef WIN32
  46. #if defined(_MSC_VER) && _MSC_VER <= 1200
  47. char *VisualC_funcname(const char *file, int line); /* not thread safe! */
  48. #define __FUNCTION__ VisualC_funcname(__FILE__, __LINE__)
  49. #endif
  50. #endif
  51. extern void hlog_verbose(const char *FUNC, const char *format, ...);
  52. extern void hlog_debug(const char *FUNC, const char *format, ...);
  53. extern void hlog_info(const char *FUNC, const char *format, ...);
  54. extern void hlog_warn(const char *FUNC, const char *format, ...);
  55. extern void hlog_error(const char *FUNC, const char *format, ...);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. /*
  60. * XXX: This isn't the "right" way
  61. *
  62. * #define log_debug(fmt, ...) fprintf(stderr, "EMERGENCY: %s: " fmt "\n", \
  63. * __FUNCTION__, ## __VA_ARGS__)
  64. *
  65. */
  66. #define log_verbose1(a1) hlog_verbose(__FUNCTION__, a1)
  67. #define log_verbose2(a1,a2) hlog_verbose(__FUNCTION__, a1,a2)
  68. #define log_verbose3(a1,a2,a3) hlog_verbose(__FUNCTION__, a1,a2,a3)
  69. #define log_verbose4(a1,a2,a3,a4) hlog_verbose(__FUNCTION__, a1,a2,a3,a4)
  70. #define log_verbose5(a1,a2,a3,a4,a5) hlog_verbose(__FUNCTION__, a1,a2,a3,a4,a5)
  71. #define log_debug1(a1) hlog_debug(__FUNCTION__, a1)
  72. #define log_debug2(a1,a2) hlog_debug(__FUNCTION__, a1,a2)
  73. #define log_debug3(a1,a2,a3) hlog_debug(__FUNCTION__, a1,a2,a3)
  74. #define log_debug4(a1,a2,a3,a4) hlog_debug(__FUNCTION__, a1,a2,a3,a4)
  75. #define log_debug5(a1,a2,a3,a4,a5) hlog_debug(__FUNCTION__, a1,a2,a3,a4,a5)
  76. #define log_info1(a1) hlog_info(__FUNCTION__, a1)
  77. #define log_info2(a1,a2) hlog_info(__FUNCTION__, a1,a2)
  78. #define log_info3(a1,a2,a3) hlog_info(__FUNCTION__, a1,a2,a3)
  79. #define log_info4(a1,a2,a3,a4) hlog_info(__FUNCTION__, a1,a2,a3,a4)
  80. #define log_info5(a1,a2,a3,a4,a5) hlog_info(__FUNCTION__, a1,a2,a3,a4,a5)
  81. #define log_warn1(a1) hlog_warn(__FUNCTION__, a1)
  82. #define log_warn2(a1,a2) hlog_warn(__FUNCTION__, a1,a2)
  83. #define log_warn3(a1,a2,a3) hlog_warn(__FUNCTION__, a1,a2,a3)
  84. #define log_warn4(a1,a2,a3,a4) hlog_warn(__FUNCTION__, a1,a2,a3,a4)
  85. #define log_warn5(a1,a2,a3,a4,a5) hlog_warn(__FUNCTION__, a1,a2,a3,a4,a5)
  86. #define log_error1(a1) hlog_error(__FUNCTION__, a1)
  87. #define log_error2(a1,a2) hlog_error(__FUNCTION__, a1,a2)
  88. #define log_error3(a1,a2,a3) hlog_error(__FUNCTION__, a1,a2,a3)
  89. #define log_error4(a1,a2,a3,a4) hlog_error(__FUNCTION__, a1,a2,a3,a4)
  90. #define log_error5(a1,a2,a3,a4,a5) hlog_error(__FUNCTION__, a1,a2,a3,a4,a5)
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif