aboutsummaryrefslogtreecommitdiffstats
path: root/src/logging.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-11-17 08:37:54 +0000
committerWerner Koch <[email protected]>2017-11-17 08:48:30 +0000
commit1b653e7f37e2eb2a8f590a43651eb8aecbe8756e (patch)
tree07981a1260494dc7a94e3e266743fb58070416a2 /src/logging.h
parentNew configure options and macros for internal use. (diff)
downloadlibgpg-error-1b653e7f37e2eb2a8f590a43651eb8aecbe8756e.tar.gz
libgpg-error-1b653e7f37e2eb2a8f590a43651eb8aecbe8756e.zip
core: Add logging API.
* src/visibility.c (gpgrt_get_errorcount): New API. (gpgrt_inc_errorcount): New API. (gpgrt_log_set_sink): New API. (gpgrt_log_set_socket_dir_cb): New API. (gpgrt_log_set_pid_suffix_cb): New API. (gpgrt_log_set_prefix): New API. (gpgrt_log_get_prefix): New API. (gpgrt_log_test_fd): New API. (gpgrt_log_get_fd): New API. (gpgrt_log_get_stream): New API. (gpgrt_log): New API. (gpgrt_logv): New API. (gpgrt_logv_prefix): New API. (gpgrt_log_string): New API. (gpgrt_log_info): New API. (gpgrt_log_error): New API. (gpgrt_log_fatal): New API. (gpgrt_log_bug): New API. (gpgrt_log_debug): New API. (gpgrt_log_debug_string): New API. (gpgrt_log_printf): New API. (gpgrt_log_flush): New API. (gpgrt_log_printhex): New API. (gpgrt_log_clock): New API. (_gpgrt_log_assert): New function for the ABI. * src/visibility.h: Add corresponding macros. * src/gpg-error.def.in: Add new functions. * src/gpg-error.vers: Add new functions. * src/gpg-error.h.in (GPGRT_LOG_WITH_PREFIX): New constant. (GPGRT_LOG_WITH_TIME): New constant. (GPGRT_LOG_WITH_PID): New constant. (GPGRT_LOG_RUN_DETACHED): New constant. (GPGRT_LOG_NO_REGISTRY): New constant. (GPGRT_LOG_BEGIN): New enum value. (GPGRT_LOG_CONT): New enum value. (GPGRT_LOG_INFO): New enum value. (GPGRT_LOG_WARN): New enum value. (GPGRT_LOG_ERROR): New enum value. (GPGRT_LOG_FATAL): New enum value. (GPGRT_LOG_BUG): New enum value. (GPGRT_LOG_DEBUG): New enum value. (log_get_errorcount, log_inc_errorcount, log_set_file, log_set_fd) (log_set_stream, log_set_socket_dir_cb, log_set_pid_suffix_cb) (log_set_prefix, log_get_prefix, log_test_fd, log_get_fd) (log_get_stream, log_log, log_logv, log_logv_prefix, log_string) (log_bug, log_fatal, log_error, log_info, log_debug, log_debug_string) (log_printf, log_printhex, log_clock) (log_flush) [GPGRT_ENABLE_LOG_MACROS]: New wrapper macros. (gpgrt_assert): New macro. * src/gpgrt-int.h: Add prototypes for logging.c. (gpgrt_assert): Redefine for internal use. * src/logging.h: Remove. * src/logging.c: Include gpgrt-int.h instead of the stuff from GnuPG. Use _gpgrt malloc funcsions and the internal versions of the estream functions. Rename all public fucntions with a _gpgrt_ prefix. (print_prefix): Return the printed length. (_gpgrt_logv_internal): Ditto. (_gpgrt_log_printhex): Change order of args and turn into a printf like function. (_gpgrt_logv_printhex): New. Take the core of the former log_printhex. (_gpgrt_log_clock): Turn into a printf like functions. (_gpgrt_logv_clock): New. Take the core of the former log_clock. -- This logging API is a slightly modified version of what we are using in GnuPG. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/logging.h')
-rw-r--r--src/logging.h107
1 files changed, 0 insertions, 107 deletions
diff --git a/src/logging.h b/src/logging.h
deleted file mode 100644
index 2fae303..0000000
--- a/src/logging.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* logging.h - Definitions for logging.c
- * Copyright (C) 1998-2001, 2003-2006, 2009-2010,
- * 2017 Free Software Foundation, Inc.
- * Copyright (C) 1998-1999, 2001-2006, 2008-2017 Werner Koch
- *
- * This file is part of Libgpg-error.
- *
- * Libgpg-error is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * Libgpg-error is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <https://www.gnu.org/licenses/>.
- *
- * This file was originally a part of GnuPG.
- */
-
-#ifndef _GPGRT_LOGGING_H
-#define _GPGRT_LOGGING_H
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <gpg-error.h>
-#include "mischelp.h"
-#include "w32help.h"
-
-int log_get_errorcount (int clear);
-void log_inc_errorcount (void);
-void log_set_file( const char *name );
-void log_set_fd (int fd);
-void log_set_socket_dir_cb (const char *(*fnc)(void));
-void log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
-void log_set_prefix (const char *text, unsigned int flags);
-const char *log_get_prefix (unsigned int *flags);
-int log_test_fd (int fd);
-int log_get_fd(void);
-estream_t log_get_stream (void);
-
-#ifdef GPGRT_HAVE_MACRO_FUNCTION
- void bug_at (const char *file, int line, const char *func)
- GPGRT_ATTR_NORETURN;
- void _log_assert (const char *expr, const char *file, int line,
- const char *func) GPGRT_ATTR_NORETURN;
-# define BUG() bug_at( __FILE__ , __LINE__, __FUNCTION__)
-# define log_assert(expr) \
- ((expr) \
- ? (void) 0 \
- : _log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
-#else /*!GPGRT_HAVE_MACRO_FUNCTION*/
- void bug_at (const char *file, int line);
- void _log_assert (const char *expr, const char *file, int line);
-# define BUG() bug_at( __FILE__ , __LINE__ )
-# define log_assert(expr) \
- ((expr) \
- ? (void) 0 \
- : _log_assert (#expr, __FILE__, __LINE__))
-#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
-
-/* Flag values for log_set_prefix. */
-#define GPGRT_LOG_WITH_PREFIX 1
-#define GPGRT_LOG_WITH_TIME 2
-#define GPGRT_LOG_WITH_PID 4
-#define GPGRT_LOG_RUN_DETACHED 256
-#define GPGRT_LOG_NO_REGISTRY 512
-
-/* Log levels as used by log_log. */
-enum jnlib_log_levels {
- GPGRT_LOG_BEGIN,
- GPGRT_LOG_CONT,
- GPGRT_LOG_INFO,
- GPGRT_LOG_WARN,
- GPGRT_LOG_ERROR,
- GPGRT_LOG_FATAL,
- GPGRT_LOG_BUG,
- GPGRT_LOG_DEBUG
-};
-void log_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
-void log_logv (int level, const char *fmt, va_list arg_ptr);
-void log_logv_with_prefix (int level, const char *prefix,
- const char *fmt, va_list arg_ptr);
-void log_string (int level, const char *string);
-void log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
-void log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
-void log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
-void log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
-void log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
-void log_debug_with_string (const char *string, const char *fmt,
- ...) GPGRT_ATTR_PRINTF(2,3);
-void log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
-void log_flush (void);
-
-/* Print a hexdump of BUFFER. With TEXT passes as NULL print just the
- raw dump, with TEXT being an empty string, print a trailing
- linefeed, otherwise print an entire debug line with TEXT followed
- by the hexdump and a final LF. */
-void log_printhex (const char *text, const void *buffer, size_t length);
-
-void log_clock (const char *string);
-
-
-#endif /*_GPGRT_LOGGING_H*/