Fix errors found by new find-doc-nits
[openssl.git] / doc / man3 / OSSL_CMP_log_open.pod
1 =pod
2
3 =head1 NAME
4
5 OSSL_CMP_log_open,
6 OSSL_CMP_log_close,
7 OSSL_CMP_alert,
8 OSSL_CMP_err,
9 OSSL_CMP_warn,
10 OSSL_CMP_info,
11 OSSL_CMP_debug,
12 OSSL_CMP_log,
13 OSSL_CMP_log1,
14 OSSL_CMP_log2,
15 OSSL_CMP_log3,
16 OSSL_CMP_log4,
17 OSSL_CMP_severity,
18 OSSL_CMP_LOG_EMERG,
19 OSSL_CMP_LOG_ALERT,
20 OSSL_CMP_LOG_CRIT,
21 OSSL_CMP_LOG_ERR,
22 OSSL_CMP_LOG_WARNING,
23 OSSL_CMP_LOG_NOTICE,
24 OSSL_CMP_LOG_INFO,
25 OSSL_CMP_LOG_DEBUG,
26 OSSL_CMP_print_errors_cb
27 - functions for logging and error reporting
28
29 =head1 SYNOPSIS
30
31  #include <openssl/cmp_util.h>
32
33  int  OSSL_CMP_log_open(void);
34  void OSSL_CMP_log_close(void);
35  #define OSSL_CMP_alert(msg)
36  #define OSSL_CMP_err(msg)
37  #define OSSL_CMP_warn(msg)
38  #define OSSL_CMP_info(msg)
39  #define OSSL_CMP_debug(msg)
40  #define OSSL_CMP_log(level, msg)
41  #define OSSL_CMP_log1(level, fmt, arg1)
42  #define OSSL_CMP_log2(level, fmt, arg1, arg2)
43  #define OSSL_CMP_log3(level, fmt, arg1, arg2, arg3)
44  #define OSSL_CMP_log4(level, fmt, arg1, arg2, arg3, arg4)
45
46  /* severity level declarations resemble those from syslog.h */
47  typedef int OSSL_CMP_severity;
48  #define OSSL_CMP_LOG_EMERG   0
49  #define OSSL_CMP_LOG_ALERT   1
50  #define OSSL_CMP_LOG_CRIT    2
51  #define OSSL_CMP_LOG_ERR     3
52  #define OSSL_CMP_LOG_WARNING 4
53  #define OSSL_CMP_LOG_NOTICE  5
54  #define OSSL_CMP_LOG_INFO    6
55  #define OSSL_CMP_LOG_DEBUG   7
56  typedef int (*OSSL_cmp_log_cb_t) (const char *component,
57                                    const char *file, int line,
58                                    OSSL_CMP_severity level, const char *msg);
59
60  void OSSL_CMP_print_errors_cb(OSSL_cmp_log_cb_t log_fn);
61
62 =head1 DESCRIPTION
63
64 The logging and error reporting facility described here contains
65 convenience functions for CMP-specific logging via the trace API,
66 including a string prefix mirroring the severity levels of syslog.h,
67 and enhancements of the error queue mechanism needed for large diagnostic
68 messages produced by the CMP library in case of certificate validation failures.
69
70 When an interesting activity is performed or an error occurs, some detail
71 should be provided for user information, debugging, and auditing purposes.
72 A CMP application can obtain this information by providing a callback function
73 with the following type:
74
75  typedef void (*OSSL_cmp_log_cb_t)(const char *component,
76                                    const char *file, int line,
77                                    OSSL_CMP_severity level, const char *msg);
78
79 The parameters may provide
80 a component identifier (which may be a library name or function name) or NULL,
81 a file pathname or NULL,
82 a line number or 0 indicating the source code location,
83 a severity level, and
84 a message string describing the nature of the event, terminated by '\n'.
85
86 Even when an activity is successful some warnings may be useful and some degree
87 of auditing may be required. Therefore the logging facility supports a severity
88 level and the callback function has a B<level> parameter indicating such a
89 level, such that error, warning, info, debug, etc. can be treated differently.
90 The callback is activated only when the severity level is sufficient according
91 to the current level of verbosity, which by default is OSSL_CMP_LOG_INFO.
92
93 The callback function may itself do non-trivial tasks like writing to
94 a log file or remote stream, which in turn may fail.
95 Therefore the function should return 1 on success and 0 on failure.
96
97 OSSL_CMP_log_open() initializes the CMP-specific logging facility to output
98 everything to STDOUT. It fails if the integrated tracing is disabled or STDIO
99 is not available. It may be called during application startup.
100 Alternatively, L<OSSL_CMP_CTX_set_log_cb(3)> can be used for more flexibility.
101 As long as neither if the two is used any logging output is ignored.
102
103 OSSL_CMP_log_close() may be called when all activities are finished to flush
104 any pending CMP-specific log output and deallocate related resources.
105 It may be called multiple times. It does get called at OpenSSL stutdown.
106
107 OSSL_CMP_alert() outputs a simple alert message via the trace API.
108 OSSL_CMP_err() outputs a simple error message via the trace API.
109 OSSL_CMP_warn() outputs a simple warning message via the trace API.
110 OSSL_CMP_info() outputs a simple info message via the trace API.
111 OSSL_CMP_debug() outputs a simple debug message via the trace API.
112
113 Note that due to the design of the trace API used, the log functions have no
114 effect unless the B<enable-trace> option is used during build configuration.
115
116 OSSL_CMP_print_errors_cb() outputs any entries in the OpenSSL error queue.
117 It is similar to B<ERR_print_errors_cb()> but uses the CMP log callback function
118 C<log_fn> for uniformity with CMP logging if not B<NULL>. Otherwise it uses
119 B<ERR_print_errors(3)> to print to STDERR (unless OPENSSL_NO_STDIO is defined).
120
121 =head1 RETURN VALUES
122
123 OSSL_CMP_log_close() and OSSL_CMP_print_errors_cb() do not return anything.
124
125 All other functions return 1 on success, 0 on error.
126
127 =head1 HISTORY
128
129 The OpenSSL CMP support was added in OpenSSL 3.0.
130
131 =head1 COPYRIGHT
132
133 Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
134
135 Licensed under the Apache License 2.0 (the "License").  You may not use
136 this file except in compliance with the License.  You can obtain a copy
137 in the file LICENSE in the source distribution or at
138 L<https://www.openssl.org/source/license.html>.
139
140 =cut