File Manager / inc / utils /

logger.h

  1. /*
  2. * Copyright 2014 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17.  
  18. #ifndef __LOGGER_H__
  19. #define __LOGGER_H__
  20.  
  21. #include <dlog.h>
  22.  
  23. #ifdef LOG_TAG
  24. #undef LOG_TAG
  25. #endif
  26. #define LOG_TAG "$(appName)"
  27.  
  28. #define MODULE_INFO (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
  29.  
  30. #define INF(fmt, arg...) dlog_print(DLOG_INFO, \
  31. LOG_TAG, "%s: %s(%d) > " fmt, MODULE_INFO, \
  32. __func__, __LINE__, ##arg)
  33.  
  34. #define DBG(fmt, arg...) dlog_print(DLOG_DEBUG, \
  35. LOG_TAG, "%s: %s(%d) > " fmt, MODULE_INFO, \
  36. __func__, __LINE__, ##arg)
  37.  
  38. #define WARN(fmt, arg...) dlog_print(DLOG_WARN, \
  39. LOG_TAG, "%s: %s(%d) > " fmt, MODULE_INFO, \
  40. __func__, __LINE__, ##arg)
  41.  
  42. #define ERR(fmt, arg...) dlog_print(DLOG_ERROR, \
  43. LOG_TAG, "%s: %s(%d) > " fmt, MODULE_INFO, \
  44. __func__, __LINE__, ##arg)
  45.  
  46. #define RETM_IF(expr, fmt, arg...) \
  47. { \
  48. if (expr) { \
  49. ERR(fmt, ##arg); \
  50. return; \
  51. } \
  52. }
  53.  
  54. #define RETVM_IF(expr, val, fmt, arg...) \
  55. { \
  56. if (expr) { \
  57. ERR(fmt, ##arg); \
  58. return (val); \
  59. } \
  60. }
  61.  
  62. #endif /* __LOGGER_H__ */