usnic_log.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. *
  17. */
  18. #ifndef USNIC_LOG_H_
  19. #define USNIC_LOG_H_
  20. #include "usnic.h"
  21. extern unsigned int usnic_log_lvl;
  22. #define USNIC_LOG_LVL_NONE (0)
  23. #define USNIC_LOG_LVL_ERR (1)
  24. #define USNIC_LOG_LVL_INFO (2)
  25. #define USNIC_LOG_LVL_DBG (3)
  26. #define usnic_printk(lvl, args...) \
  27. do { \
  28. printk(lvl "%s:%s:%d: ", DRV_NAME, __func__, \
  29. __LINE__); \
  30. printk(args); \
  31. } while (0)
  32. #define usnic_dbg(args...) \
  33. do { \
  34. if (unlikely(usnic_log_lvl >= USNIC_LOG_LVL_DBG)) { \
  35. usnic_printk(KERN_INFO, args); \
  36. } \
  37. } while (0)
  38. #define usnic_info(args...) \
  39. do { \
  40. if (usnic_log_lvl >= USNIC_LOG_LVL_INFO) { \
  41. usnic_printk(KERN_INFO, args); \
  42. } \
  43. } while (0)
  44. #define usnic_err(args...) \
  45. do { \
  46. if (usnic_log_lvl >= USNIC_LOG_LVL_ERR) { \
  47. usnic_printk(KERN_ERR, args); \
  48. } \
  49. } while (0)
  50. #endif /* !USNIC_LOG_H_ */