ereport.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2021 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 <stdarg.h>
  23. #include <stdio.h> /* vsprintf */
  24. #include <string.h> /* strcpy */
  25. #include <time.h> /* localtime */
  26. /* taken from ACL plugin acl.h */
  27. #define ACL_PLUGIN_NAME "NSACLPlugin"
  28. NSAPI_PUBLIC int ereport_v(int degree, char *fmt, va_list args)
  29. {
  30. char errstr[MAX_ERROR_LEN];
  31. util_vsnprintf(errstr, MAX_ERROR_LEN, fmt, args);
  32. switch (degree)
  33. {
  34. case LOG_WARN:
  35. case LOG_FAILURE:
  36. case LOG_INFORM:
  37. case LOG_VERBOSE:
  38. case LOG_MISCONFIG:
  39. // slapi_log_err(SLAPI_LOG_PLUGIN, ACL_PLUGIN_NAME, errstr);
  40. break;
  41. case LOG_SECURITY:
  42. // slapi_log_err(SLAPI_LOG_ACL, ACL_PLUGIN_NAME, errstr);
  43. break;
  44. case LOG_CATASTROPHE:
  45. // slapi_log_err(SLAPI_LOG_ERR, ACL_PLUGIN_NAME, errstr);
  46. break;
  47. default:
  48. break;
  49. }
  50. return IO_OKAY;
  51. }
  52. NSAPI_PUBLIC int ereport(int degree, char *fmt, ...)
  53. {
  54. va_list args;
  55. int rv;
  56. va_start(args, fmt);
  57. rv = ereport_v(degree, fmt, args);
  58. va_end(args);
  59. return rv;
  60. }