ereport.cpp 1.7 KB

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