diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2022-05-28 20:26:43 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2022-09-07 23:04:25 +0200 |
commit | 8a2ec00d7f4bc34ca9111561699ec5ac03a3923e (patch) | |
tree | 02c507169ac28ca8627e6aa36f2e5985b31adbfd /apps/include | |
parent | 5e87fddc971210ebb6df3fe77eeb858cd0bc4dea (diff) |
apps/lib/http_server.{c,h}: clean up logging and move it to log.{c,h}
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18434)
Diffstat (limited to 'apps/include')
-rw-r--r-- | apps/include/http_server.h | 28 | ||||
-rw-r--r-- | apps/include/log.h | 50 |
2 files changed, 51 insertions, 27 deletions
diff --git a/apps/include/http_server.h b/apps/include/http_server.h index e80e29d8c5..4811e6be40 100644 --- a/apps/include/http_server.h +++ b/apps/include/http_server.h @@ -11,6 +11,7 @@ # define OSSL_HTTP_SERVER_H # include "apps.h" +# include "log.h" # ifndef HAVE_FORK # if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) @@ -31,37 +32,10 @@ # define HTTP_DAEMON # include <sys/types.h> # include <sys/wait.h> -# include <syslog.h> # include <signal.h> # define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */ # endif -# undef LOG_TRACE -# undef LOG_DEBUG -# undef LOG_INFO -# undef LOG_WARNING -# undef LOG_ERR -# define LOG_TRACE 8 -# define LOG_DEBUG 7 -# define LOG_INFO 6 -# define LOG_WARNING 4 -# define LOG_ERR 3 - -/*- - * Output a message using the trace API with the given category - * if the category is >= 0 and tracing is enabled. - * Log the message to syslog if multi-threaded HTTP_DAEMON, else to bio_err - * if the verbosity is sufficient for the given level of severity. - * category: trace category as defined in trace.h, or -1 - * prog: the name of the current app, or NULL - * level: the severity of the message, e.g., LOG_ERR - * fmt: message format, which should not include a trailing newline - * ...: potential extra parameters like with printf() - * returns nothing - */ -void trace_log_message(int category, - const char *prog, int level, const char *fmt, ...); - # ifndef OPENSSL_NO_SOCK /*- * Initialize an HTTP server, setting up its listening BIO diff --git a/apps/include/log.h b/apps/include/log.h new file mode 100644 index 0000000000..1b8b58d41a --- /dev/null +++ b/apps/include/log.h @@ -0,0 +1,50 @@ +/* + * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_APPS_LOG_H +# define OSSL_APPS_LOG_H + +# include <openssl/bio.h> +# if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) \ + && !defined(OPENSSL_NO_SOCK) && !defined(OPENSSL_NO_POSIX_IO) +# include <syslog.h> +# else +# define LOG_EMERG 0 +# define LOG_ALERT 1 +# define LOG_CRIT 2 +# define LOG_ERR 3 +# define LOG_WARNING 4 +# define LOG_NOTICE 5 +# define LOG_INFO 6 +# define LOG_DEBUG 7 +# endif + +# undef LOG_TRACE +# define LOG_TRACE (LOG_DEBUG + 1) + +int log_set_verbosity(const char *prog, int level); +int log_get_verbosity(void); + +/*- + * Output a message using the trace API with the given category + * if the category is >= 0 and tracing is enabled. + * Log the message to syslog if multi-threaded HTTP_DAEMON, else to bio_err + * if the verbosity is sufficient for the given level of severity. + * Yet cannot do both types of output in strict ANSI mode. + * category: trace category as defined in trace.h, or -1 + * prog: the name of the current app, or NULL + * level: the severity of the message, e.g., LOG_ERR + * fmt: message format, which should not include a trailing newline + * ...: potential extra parameters like with printf() + * returns nothing + */ +void trace_log_message(int category, + const char *prog, int level, const char *fmt, ...); + +#endif /* OSSL_APPS_LOG_H */ |