modlog.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #ifndef H_MODLOG_
  20. #define H_MODLOG_
  21. #include <stdio.h>
  22. #include <stdint.h>
  23. #include "log_common/log_common.h"
  24. #define MODLOG_MODULE_DFLT 255
  25. #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__
  26. #define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \
  27. printf((ml_msg_), ##__VA_ARGS__)
  28. #else
  29. #define MODLOG_DEBUG(ml_mod_, ...) IGNORE(__VA_ARGS__)
  30. #endif
  31. #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_INFO || defined __DOXYGEN__
  32. #define MODLOG_INFO(ml_mod_, ml_msg_, ...) \
  33. printf((ml_msg_), ##__VA_ARGS__)
  34. #else
  35. #define MODLOG_INFO(ml_mod_, ...) IGNORE(__VA_ARGS__)
  36. #endif
  37. #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_WARN || defined __DOXYGEN__
  38. #define MODLOG_WARN(ml_mod_, ml_msg_, ...) \
  39. printf((ml_msg_), ##__VA_ARGS__)
  40. #else
  41. #define MODLOG_WARN(ml_mod_, ...) IGNORE(__VA_ARGS__)
  42. #endif
  43. #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_ERROR || defined __DOXYGEN__
  44. #define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \
  45. printf((ml_msg_), ##__VA_ARGS__)
  46. #else
  47. #define MODLOG_ERROR(ml_mod_, ...) IGNORE(__VA_ARGS__)
  48. #endif
  49. #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_CRITICAL || defined __DOXYGEN__
  50. #define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \
  51. printf((ml_msg_), ##__VA_ARGS__)
  52. #else
  53. #define MODLOG_CRITICAL(ml_mod_, ...) IGNORE(__VA_ARGS__)
  54. #endif
  55. #define MODLOG(ml_lvl_, ml_mod_, ...) \
  56. MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__)
  57. #endif