clogger.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // -*- C -*-
  2. /**
  3. * Module: Log4CPLUS
  4. * File: clogger.h
  5. * Created: 01/2011
  6. * Author: Jens Rehsack
  7. *
  8. *
  9. * Copyright 2011-2017 Jens Rehsack & Tad E. Smith
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. */
  23. /** @file
  24. * This header defines the C API for log4cplus and the logging macros. */
  25. #ifndef LOG4CPLUS_CLOGGERHEADER_
  26. #define LOG4CPLUS_CLOGGERHEADER_
  27. #include <log4cplus/config.hxx>
  28. #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #endif
  35. // TODO UNICDE capable
  36. typedef void * log4cplus_logger_t;
  37. typedef log4cplus_logger_t logger_t;
  38. typedef int log4cplus_loglevel_t;
  39. typedef log4cplus_loglevel_t loglevel_t;
  40. #define L4CP_OFF_LOG_LEVEL 60000
  41. #define L4CP_FATAL_LOG_LEVEL 50000
  42. #define L4CP_ERROR_LOG_LEVEL 40000
  43. #define L4CP_WARN_LOG_LEVEL 30000
  44. #define L4CP_INFO_LOG_LEVEL 20000
  45. #define L4CP_DEBUG_LOG_LEVEL 10000
  46. #define L4CP_TRACE_LOG_LEVEL 0
  47. #define L4CP_ALL_LOG_LEVEL TRACE_LOG_LEVEL
  48. #define L4CP_NOT_SET_LOG_LEVEL -1
  49. #ifdef UNICODE
  50. typedef wchar_t log4cplus_char_t;
  51. #else
  52. typedef char log4cplus_char_t;
  53. #endif // UNICODE
  54. #if ! defined (LOG4CPLUS_TEXT)
  55. #ifdef UNICODE
  56. # define LOG4CPLUS_TEXT2(STRING) L##STRING
  57. #else
  58. # define LOG4CPLUS_TEXT2(STRING) STRING
  59. #endif // UNICODE
  60. #define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING)
  61. #endif // LOG4CPLUS_TEXT
  62. LOG4CPLUS_EXPORT void * log4cplus_initialize(void);
  63. LOG4CPLUS_EXPORT int log4cplus_deinitialize(void * initializer);
  64. LOG4CPLUS_EXPORT int log4cplus_file_configure(const log4cplus_char_t *pathname);
  65. LOG4CPLUS_EXPORT int log4cplus_file_reconfigure(const log4cplus_char_t *pathname);
  66. LOG4CPLUS_EXPORT int log4cplus_str_configure(const log4cplus_char_t *config);
  67. LOG4CPLUS_EXPORT int log4cplus_str_reconfigure(const log4cplus_char_t *config);
  68. LOG4CPLUS_EXPORT int log4cplus_basic_configure(void);
  69. LOG4CPLUS_EXPORT int log4cplus_basic_reconfigure(int logToStdErr);
  70. LOG4CPLUS_EXPORT void log4cplus_shutdown(void);
  71. LOG4CPLUS_EXPORT int log4cplus_logger_exists(const log4cplus_char_t *name);
  72. LOG4CPLUS_EXPORT int log4cplus_logger_is_enabled_for(
  73. const log4cplus_char_t *name, log4cplus_loglevel_t ll);
  74. LOG4CPLUS_EXPORT int log4cplus_logger_log(const log4cplus_char_t *name,
  75. log4cplus_loglevel_t ll, const log4cplus_char_t *msgfmt, ...)
  76. LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4);
  77. LOG4CPLUS_EXPORT int log4cplus_logger_log_str(const log4cplus_char_t *name,
  78. log4cplus_loglevel_t ll, const log4cplus_char_t *msg);
  79. LOG4CPLUS_EXPORT int log4cplus_logger_force_log(const log4cplus_char_t *name,
  80. log4cplus_loglevel_t ll, const log4cplus_char_t *msgfmt, ...)
  81. LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4);
  82. LOG4CPLUS_EXPORT int log4cplus_logger_force_log_str(const log4cplus_char_t *name,
  83. log4cplus_loglevel_t ll, const log4cplus_char_t *msg);
  84. //! CallbackAppender callback type.
  85. typedef void (* log4cplus_log_event_callback_t)(void * cookie,
  86. log4cplus_char_t const * message, log4cplus_char_t const * loggerName,
  87. log4cplus_loglevel_t ll, log4cplus_char_t const * thread,
  88. log4cplus_char_t const * thread2,
  89. unsigned long long timestamp_secs, unsigned long timestamp_usecs,
  90. log4cplus_char_t const * file, log4cplus_char_t const * function, int line);
  91. LOG4CPLUS_EXPORT int log4cplus_add_callback_appender(
  92. const log4cplus_char_t * logger, log4cplus_log_event_callback_t callback,
  93. void * cookie);
  94. // Custom LogLevel
  95. LOG4CPLUS_EXPORT int log4cplus_add_log_level(unsigned int ll,
  96. const log4cplus_char_t *ll_name);
  97. LOG4CPLUS_EXPORT int log4cplus_remove_log_level(unsigned int ll,
  98. const log4cplus_char_t *ll_name);
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif /*?LOG4CPLUS_CLOGGERHEADER_*/