log.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OSSL_APPS_LOG_H
  10. # define OSSL_APPS_LOG_H
  11. # include <openssl/bio.h>
  12. # if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) \
  13. && !defined(OPENSSL_NO_SOCK) && !defined(OPENSSL_NO_POSIX_IO)
  14. # include <syslog.h>
  15. # else
  16. # define LOG_EMERG 0
  17. # define LOG_ALERT 1
  18. # define LOG_CRIT 2
  19. # define LOG_ERR 3
  20. # define LOG_WARNING 4
  21. # define LOG_NOTICE 5
  22. # define LOG_INFO 6
  23. # define LOG_DEBUG 7
  24. # endif
  25. # undef LOG_TRACE
  26. # define LOG_TRACE (LOG_DEBUG + 1)
  27. int log_set_verbosity(const char *prog, int level);
  28. int log_get_verbosity(void);
  29. /*-
  30. * Output a message using the trace API with the given category
  31. * if the category is >= 0 and tracing is enabled.
  32. * Log the message to syslog if multi-threaded HTTP_DAEMON, else to bio_err
  33. * if the verbosity is sufficient for the given level of severity.
  34. * Yet cannot do both types of output in strict ANSI mode.
  35. * category: trace category as defined in trace.h, or -1
  36. * prog: the name of the current app, or NULL
  37. * level: the severity of the message, e.g., LOG_ERR
  38. * fmt: message format, which should not include a trailing newline
  39. * ...: potential extra parameters like with printf()
  40. * returns nothing
  41. */
  42. void trace_log_message(int category,
  43. const char *prog, int level, const char *fmt, ...);
  44. #endif /* OSSL_APPS_LOG_H */