Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
#ifndef LOGGER_H
#define LOGGER_H
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <proton/import_export.h>
#include <proton/object.h>
#include <stdarg.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pn_logger_t pn_logger_t;
typedef enum pn_log_subsystem_t {
PN_SUBSYSTEM_NONE = 0,
PN_SUBSYSTEM_MEMORY = 1,
PN_SUBSYSTEM_IO = 2,
PN_SUBSYSTEM_EVENT = 4,
PN_SUBSYSTEM_AMQP = 8,
PN_SUBSYSTEM_SSL = 16,
PN_SUBSYSTEM_SASL = 32,
PN_SUBSYSTEM_BINDING = 64,
PN_SUBSYSTEM_ALL = 65535
} pn_log_subsystem_t; /* We hint to the compiler it can use 16 bits for this value */
typedef enum pn_log_level_t {
PN_LEVEL_NONE = 0,
PN_LEVEL_CRITICAL = 1,
PN_LEVEL_ERROR = 2,
PN_LEVEL_WARNING = 4,
PN_LEVEL_INFO = 8,
PN_LEVEL_DEBUG = 16,
PN_LEVEL_TRACE = 32,
PN_LEVEL_FRAME = 64,
PN_LEVEL_RAW = 128,
PN_LEVEL_ALL = 65535
} pn_log_level_t; /* We hint to the compiler that it can use 16 bits for this value */
typedef void (*pn_log_sink_t)(intptr_t sink_context, pn_log_subsystem_t subsystem, pn_log_level_t severity, const char *message);
PN_EXTERN pn_logger_t *pn_default_logger(void);
PN_EXTERN const char *pn_logger_level_name(pn_log_level_t level);
PN_EXTERN const char *pn_logger_subsystem_name(pn_log_subsystem_t subsystem);
PN_EXTERN void pn_logger_set_mask(pn_logger_t *logger, uint16_t subsystem, uint16_t level);
PN_EXTERN void pn_logger_reset_mask(pn_logger_t *logger, uint16_t subsystem, uint16_t level);
PN_EXTERN void pn_logger_set_log_sink(pn_logger_t *logger, pn_log_sink_t sink, intptr_t sink_context);
PN_EXTERN pn_log_sink_t pn_logger_get_log_sink(pn_logger_t *logger);
PN_EXTERN intptr_t pn_logger_get_log_sink_context(pn_logger_t *logger);
PN_EXTERN void pn_logger_logf(pn_logger_t *logger, pn_log_subsystem_t subsystem, pn_log_level_t level, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif
pn_default_logger
pn_logger_t * pn_default_logger(void)
Return the default library logger.
pn_logger_logf
void pn_logger_logf(pn_logger_t *logger, pn_log_subsystem_t subsystem, pn_log_level_t level, const char *fmt,...)
Log a printf formatted message using the logger.
pn_logger_level_name
const char * pn_logger_level_name(pn_log_level_t level)
Get a human readable name for a logger severity.
pn_logger_get_log_sink_context
intptr_t pn_logger_get_log_sink_context(pn_logger_t *logger)
Get the sink context used by a logger.
pn_logger_subsystem_name
const char * pn_logger_subsystem_name(pn_log_subsystem_t subsystem)
Get a human readable name for a logger subsystem.
pn_log_sink_t
void(* pn_log_sink_t)(intptr_t sink_context, pn_log_subsystem_t subsystem, pn_log_level_t severity, const char *message)
Callback for sinking logger messages.
Definition logger.h:126
pn_logger_set_log_sink
void pn_logger_set_log_sink(pn_logger_t *logger, pn_log_sink_t sink, intptr_t sink_context)
Set the tracing function used by a logger.
pn_logger_reset_mask
void pn_logger_reset_mask(pn_logger_t *logger, uint16_t subsystem, uint16_t level)
Clear a logger's tracing flags.
pn_logger_set_mask
void pn_logger_set_mask(pn_logger_t *logger, uint16_t subsystem, uint16_t level)
Set a logger's tracing flags.
pn_log_subsystem_t
pn_log_subsystem_t
Definitions for different subsystems that can log messages.
Definition logger.h:93
pn_logger_get_log_sink
pn_log_sink_t pn_logger_get_log_sink(pn_logger_t *logger)
Get the tracing function used by a logger.
pn_log_level_t
pn_log_level_t
Definitions for different severities of log messages Note that these are exclusive bits so that you c...
Definition logger.h:110
pn_logger_t
struct pn_logger_t pn_logger_t
The logger object allows library logging to be controlled.
Definition logger.h:86
PN_SUBSYSTEM_NONE
@ PN_SUBSYSTEM_NONE
No subsystem.
Definition logger.h:94
PN_SUBSYSTEM_IO
@ PN_SUBSYSTEM_IO
Low level Input/Output.
Definition logger.h:96
PN_SUBSYSTEM_SSL
@ PN_SUBSYSTEM_SSL
TLS/SSL protocol processing.
Definition logger.h:99
PN_SUBSYSTEM_MEMORY
@ PN_SUBSYSTEM_MEMORY
Memory usage.
Definition logger.h:95
PN_SUBSYSTEM_EVENT
@ PN_SUBSYSTEM_EVENT
Events.
Definition logger.h:97
PN_SUBSYSTEM_AMQP
@ PN_SUBSYSTEM_AMQP
AMQP protocol processing.
Definition logger.h:98
PN_SUBSYSTEM_BINDING
@ PN_SUBSYSTEM_BINDING
Language binding.
Definition logger.h:101
PN_SUBSYSTEM_ALL
@ PN_SUBSYSTEM_ALL
Every subsystem.
Definition logger.h:102
PN_SUBSYSTEM_SASL
@ PN_SUBSYSTEM_SASL
SASL protocol processing.
Definition logger.h:100
PN_LEVEL_FRAME
@ PN_LEVEL_FRAME
Protocol frame traces.
Definition logger.h:118
PN_LEVEL_TRACE
@ PN_LEVEL_TRACE
Detail about something that happened.
Definition logger.h:117
PN_LEVEL_RAW
@ PN_LEVEL_RAW
Raw protocol bytes.
Definition logger.h:119
PN_LEVEL_ERROR
@ PN_LEVEL_ERROR
Something went wrong.
Definition logger.h:113
PN_LEVEL_NONE
@ PN_LEVEL_NONE
No level.
Definition logger.h:111
PN_LEVEL_WARNING
@ PN_LEVEL_WARNING
Something unusual happened but not necessarily an error.
Definition logger.h:114
PN_LEVEL_DEBUG
@ PN_LEVEL_DEBUG
Something you might want to know about happened.
Definition logger.h:116
PN_LEVEL_CRITICAL
@ PN_LEVEL_CRITICAL
Something is wrong and can't be fixed - probably a library bug.
Definition logger.h:112
PN_LEVEL_INFO
@ PN_LEVEL_INFO
Something that might be interesting happened.
Definition logger.h:115
PN_LEVEL_ALL
@ PN_LEVEL_ALL
Every possible level.
Definition logger.h:120