log.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2009 1&1 Internet AG
  3. *
  4. * This file is part of sip-router, a free SIP server.
  5. *
  6. * sip-router is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * sip-router is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef _LOG_H_
  21. #define _LOG_H_
  22. #include <syslog.h>
  23. void init_log(char *_prgname, int _use_syslog);
  24. void set_log_level(int level);
  25. void destroy_log(void);
  26. void pdb_log(int priority, char * format, ...);
  27. #define LEMERG(fmt, args...) pdb_log(LOG_EMERG, fmt, ## args)
  28. #define LALERT(fmt, args...) pdb_log(LOG_ALERT, fmt, ## args)
  29. #define LCRIT(fmt, args...) pdb_log(LOG_CRIT, fmt, ## args)
  30. #define LERR(fmt, args...) pdb_log(LOG_ERR, fmt, ## args)
  31. #define LWARNING(fmt, args...) pdb_log(LOG_WARNING, fmt, ## args)
  32. #define LNOTICE(fmt, args...) pdb_log(LOG_NOTICE, fmt, ## args)
  33. #define LINFO(fmt, args...) pdb_log(LOG_INFO, fmt, ## args)
  34. #define LDEBUG(fmt, args...) pdb_log(LOG_DEBUG, fmt, ## args)
  35. /* several shell exit codes for the application pdbt */
  36. #define PDB_OK 0 /* Everything ok */
  37. #define PDB_USE_ERROR 1 /* Wrong usage of application (unknown command, file not found, etc.) */
  38. #define PDB_NOT_IN_PDB 2 /* A queried number is not in the pdb */
  39. #define PDB_TIMEOUT 3 /* A timeout (server not responding) occurred */
  40. #define PDB_OTHER 4 /* Another application error occurred */
  41. #endif