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