ossl_cmp_print_log.pod 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. =pod
  2. =head1 NAME
  3. ossl_cmp_print_log,
  4. ossl_cmp_alert,
  5. ossl_cmp_err,
  6. ossl_cmp_warn,
  7. ossl_cmp_info,
  8. ossl_cmp_debug,
  9. ossl_cmp_log,
  10. ossl_cmp_log1,
  11. ossl_cmp_log2,
  12. ossl_cmp_log3,
  13. ossl_cmp_log4,
  14. ossl_cmp_log_parse_metadata,
  15. ossl_cmp_add_error_data,
  16. ossl_cmp_add_error_line
  17. - logging and error reporting support for CMP
  18. =head1 SYNOPSIS
  19. #include "cmp_local.h"
  20. int ossl_cmp_print_log(OSSL_CMP_severity level, const OSSL_CMP_CTX *ctx,
  21. const char *func, const char *file, int line,
  22. const char *level_str, const char *format, ...);
  23. #define ossl_cmp_alert(ctx, msg)
  24. #define ossl_cmp_err(ctx, msg)
  25. #define ossl_cmp_warn(ctx, msg)
  26. #define ossl_cmp_info(ctx, msg)
  27. #define ossl_cmp_debug(ctx, (msg)
  28. #define ossl_cmp_log(level, ctx, msg)
  29. #define ossl_cmp_log1(level, ctx, fmt, arg1)
  30. #define ossl_cmp_log2(level, ctx, fmt, arg1, arg2)
  31. #define ossl_cmp_log3(level, ctx, fmt, arg1, arg2, arg3)
  32. #define ossl_cmp_log4(level, ctx, fmt, arg1, arg2, arg3, arg4)
  33. const char *ossl_cmp_log_parse_metadata(const char *buf,
  34. OSSL_CMP_severity *level, char **func,
  35. char **file, int *line);
  36. #define ossl_cmp_add_error_data(txt)
  37. #define ossl_cmp_add_error_line(txt)
  38. =head1 DESCRIPTION
  39. ossl_cmp_print_log() prints CMP log messages (i.e., diagnostic info) via the
  40. log callback of the B<ctx> if present and the severity level is sufficient.
  41. If the trace API if enabled the function uses it, prepending the function name,
  42. filename, line number, and severity information to the message being output.
  43. In any case the B<level>, B<func>, B<file>, and B<line> parameters
  44. and the message constructed using the given B<format> and variable further
  45. argument list are passed to the log callback function (unless it is NULL).
  46. The B<ctx>, B<func>, B<file>, and B<level_str> arguments may be NULL.
  47. ossl_cmp_alert(), ossl_cmp_err(), ossl_cmp_warn(), ossl_cmp_info(), and
  48. ossl_cmp_debug() output a simple alert/error/warning/info/debug message
  49. via ossl_cmp_print_log().
  50. ossl_cmp_log(), ossl_cmp_log1(), ossl_cmp_log2(), ossl_cmp_log3(), and
  51. ossl_cmp_log4() output a log message with the given severity,
  52. constructing the message text from the given format and arguments.
  53. ossl_cmp_log_parse_metadata() parses the given message buffer I<buf> populated
  54. by ossl_cmp_log() etc.
  55. according to the pattern OSSL_CMP_LOG_START#level ": %s\n", filling in
  56. the variable pointed to by I<level> with the severity level or -1,
  57. the variable pointed to by I<func> with the function name string or NULL,
  58. the variable pointed to by I<file> with the filename string or NULL, and
  59. the variable pointed to by I<line> with the line number or -1.
  60. Any string returned via I<*func> and I<*file> must be freed by the caller.
  61. ossl_cmp_add_error_data() is a macro calling
  62. L<ERR_add_error_txt(3)> with the separator being ":".
  63. ossl_cmp_add_error_line() is a macro calling
  64. L<ERR_add_error_txt(3)> with the separator being "\n".
  65. =head1 RETURN VALUES
  66. ossl_cmp_log_parse_metadata() returns the pointer to the actual message text
  67. after the OSSL_CMP_LOG_PREFIX and level and ':' if found in the buffer,
  68. else the beginning of the buffer.
  69. ossl_cmp_add_error_data() and
  70. ossl_cmp_add_error_line()
  71. do not return anything.
  72. All other functions return 1 on success, 0 on error.
  73. =head1 SEE ALSO
  74. L<ERR_add_error_txt(3)>
  75. =head1 HISTORY
  76. The OpenSSL CMP support was added in OpenSSL 3.0.
  77. =head1 COPYRIGHT
  78. Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
  79. Licensed under the Apache License 2.0 (the "License"). You may not use
  80. this file except in compliance with the License. You can obtain a copy
  81. in the file LICENSE in the source distribution or at
  82. L<https://www.openssl.org/source/license.html>.
  83. =cut