log.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * log.c
  3. * Logging facilities.
  4. *
  5. * Matej Pfajfar <mp292@cam.ac.uk>
  6. */
  7. /*
  8. * Changes :
  9. * $Log$
  10. * Revision 1.1 2002/06/26 22:45:50 arma
  11. * Initial revision
  12. *
  13. * Revision 1.11 2002/06/14 20:44:57 mp292
  14. * *** empty log message ***
  15. *
  16. * Revision 1.10 2002/03/12 23:31:36 mp292
  17. * *** empty log message ***
  18. *
  19. * Revision 1.9 2002/03/02 18:55:50 mp292
  20. * LOG_DEBUG messages don't print the last errno error anymore.
  21. *
  22. * Revision 1.8 2002/01/26 22:46:48 mp292
  23. * Reviewd according to Secure-Programs-HOWTO.
  24. *
  25. * Revision 1.7 2002/01/17 15:00:43 mp292
  26. * Fixed a bug which caused malloc() generate a seg fault.
  27. *
  28. * Revision 1.6 2001/12/12 16:02:55 badbytes
  29. * Minor changes in output format.
  30. *
  31. * Revision 1.5 2001/12/12 06:48:07 badbytes
  32. * Correction - last error message now only shown if severity==LOG_DEBUG.
  33. *
  34. * Revision 1.4 2001/12/12 06:28:46 badbytes
  35. * Modified log() to print error message for last error in addition to the user-specified message.
  36. *
  37. * Revision 1.3 2001/12/07 09:38:03 badbytes
  38. * Tested.
  39. *
  40. * Revision 1.2 2001/12/06 15:43:50 badbytes
  41. * config.c compiles. Proceeding to test it.
  42. *
  43. * Revision 1.1 2001/11/21 23:03:41 mp292
  44. * log function coded and tested.
  45. * Top-level makefile.
  46. *
  47. */
  48. #include <stdio.h>
  49. #include <stdarg.h>
  50. #include <syslog.h>
  51. #include <string.h>
  52. #include <errno.h>
  53. #include "log.h"
  54. void log_internal(int severity, const char *format, va_list ap);
  55. /* Outputs a message to stdout */
  56. void log(int severity, const char *format, ...)
  57. {
  58. extern int loglevel;
  59. va_list ap;
  60. va_start(ap,format);
  61. if (severity <= loglevel)
  62. {
  63. vprintf(format,ap);
  64. printf("\n");
  65. }
  66. va_end(ap);
  67. }