ereport.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. /*
  7. * ereport.c: Records transactions, reports errors to administrators, etc.
  8. *
  9. * Rob McCool
  10. */
  11. #include "private/pprio.h" /* for nspr20 binary release */
  12. #include "netsite.h"
  13. #include "file.h" /* system_fopenWA, system_write_atomic */
  14. #include "util.h" /* util_vsprintf */
  15. #include "ereport.h"
  16. #include "slapi-plugin.h"
  17. #include "base/dbtbase.h"
  18. #include <stdarg.h>
  19. #include <stdio.h> /* vsprintf */
  20. #include <string.h> /* strcpy */
  21. #include <time.h> /* localtime */
  22. /* taken from ACL plugin acl.h */
  23. #define ACL_PLUGIN_NAME "NSACLPlugin"
  24. NSAPI_PUBLIC int ereport_v(int degree, char *fmt, va_list args)
  25. {
  26. char errstr[MAX_ERROR_LEN];
  27. util_vsnprintf(errstr, MAX_ERROR_LEN, fmt, args);
  28. switch (degree)
  29. {
  30. case LOG_WARN:
  31. case LOG_FAILURE:
  32. case LOG_INFORM:
  33. case LOG_VERBOSE:
  34. case LOG_MISCONFIG:
  35. // slapi_log_error(SLAPI_LOG_PLUGIN, ACL_PLUGIN_NAME, errstr);
  36. break;
  37. case LOG_SECURITY:
  38. // slapi_log_error(SLAPI_LOG_ACL, ACL_PLUGIN_NAME, errstr);
  39. break;
  40. case LOG_CATASTROPHE:
  41. // slapi_log_error(SLAPI_LOG_FATAL, ACL_PLUGIN_NAME, errstr);
  42. break;
  43. default:
  44. break;
  45. }
  46. return IO_OKAY;
  47. }
  48. NSAPI_PUBLIC int ereport(int degree, char *fmt, ...)
  49. {
  50. va_list args;
  51. int rv;
  52. va_start(args, fmt);
  53. rv = ereport_v(degree, fmt, args);
  54. va_end(args);
  55. return rv;
  56. }