2019-09-11 18:58:15 -04:00
|
|
|
/* Copyright (C) 2019 Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LIBIGLOO__LOGCORE_H_
|
|
|
|
#define _LIBIGLOO__LOGCORE_H_
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Put a good description of this file here
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ro.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
/* About thread safety:
|
|
|
|
* This set of functions is thread safe.
|
|
|
|
*/
|
|
|
|
|
2019-09-12 05:34:15 -04:00
|
|
|
igloo_RO_FORWARD_TYPE(igloo_logcore_t);
|
|
|
|
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Routing classes allow controling the order in which messages should be routed to outputs */
|
2019-09-15 11:53:37 -04:00
|
|
|
typedef enum {
|
2019-09-18 04:45:34 -04:00
|
|
|
/* All messages are routed to outputs of the ANY class.
|
|
|
|
* However if one output accepts the message no additional ANY class outputs are tried.
|
|
|
|
*/
|
2019-09-15 11:53:37 -04:00
|
|
|
igloo_LOGCORE_CLASS_ANY,
|
2019-09-18 04:45:34 -04:00
|
|
|
/* In addition to all other classes all messages are routed to all outputs of the ALL class. */
|
2019-09-15 11:53:37 -04:00
|
|
|
igloo_LOGCORE_CLASS_ALL,
|
2019-09-18 04:45:34 -04:00
|
|
|
/* The DEFAULT class is part of the ANY class.
|
|
|
|
* The only difference is that outputs of the DEFAULT class are always tried last.
|
|
|
|
*/
|
2019-09-15 11:53:37 -04:00
|
|
|
igloo_LOGCORE_CLASS_DEFAULT
|
|
|
|
} igloo_logcore_routingclass_t;
|
|
|
|
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Configuration structure of a single output */
|
2019-09-11 18:58:15 -04:00
|
|
|
typedef struct {
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Optional: An ID for the output. This can be used to later on reference the output */
|
2019-09-11 18:58:15 -04:00
|
|
|
char *id;
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Optional: A filename for the output. If not NULL the file is opened and the formater is attached to it */
|
2019-09-11 18:58:15 -04:00
|
|
|
char *filename;
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Required: Routing class for the output. */
|
2019-09-15 11:53:37 -04:00
|
|
|
igloo_logcore_routingclass_t routingclass;
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Optional: Limit for the recent buffer of the output or -1 to use the default. */
|
2019-09-11 18:58:15 -04:00
|
|
|
ssize_t recent_limit;
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Optional: A filter that the messages that are routed to this output must pass. */
|
2019-09-11 18:58:15 -04:00
|
|
|
igloo_filter_t *filter;
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Required: The formater to pass the message to. */
|
2019-09-11 18:58:15 -04:00
|
|
|
igloo_objecthandler_t *formater;
|
|
|
|
} igloo_logcore_output_t;
|
|
|
|
|
2019-09-18 04:45:34 -04:00
|
|
|
/* Type uses for callback called when a message is acknowledged.
|
|
|
|
*
|
|
|
|
* This callback can be used to generate a new message or trigger any action
|
|
|
|
* when another one is acknowledged.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* core
|
|
|
|
* The core that emited the event.
|
|
|
|
* object
|
|
|
|
* The message that was acknowledged.
|
|
|
|
* userdata
|
|
|
|
* A pointer that was given on igloo_logcore_set_acknowledge_cb()
|
|
|
|
* Returns:
|
|
|
|
* A new message that will be pushed into the core or igloo_RO_NULL.
|
|
|
|
* A possible igloo_LOGMSG_OPT_ASKACK flag of the message will be ignored to avoid recursion.
|
|
|
|
*/
|
2019-09-12 05:34:15 -04:00
|
|
|
typedef igloo_ro_t (*igloo_logcore_acknowledge_t)(igloo_logcore_t *core, igloo_ro_t object, void *userdata);
|
|
|
|
|
2019-09-18 04:45:34 -04:00
|
|
|
|
|
|
|
/* Configure the core.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* core
|
|
|
|
* The core to configure.
|
|
|
|
* recent_limit
|
|
|
|
* The limit for the recent message buffer or -1 for default.
|
|
|
|
* askack_limit
|
|
|
|
* The limit for the askack messages buffer or -1 for default.
|
|
|
|
* output_recent_limit
|
|
|
|
* The default limit for the per output recent message buffer or -1 for default.
|
|
|
|
* outputs
|
|
|
|
* The outputs to use.
|
|
|
|
* outputs_len
|
|
|
|
* The number of outputs to use.
|
|
|
|
*/
|
2019-09-18 04:04:50 -04:00
|
|
|
igloo_error_t igloo_logcore_configure(igloo_logcore_t *core, ssize_t recent_limit, ssize_t askack_limit, ssize_t output_recent_limit, const igloo_logcore_output_t *outputs, size_t outputs_len);
|
2019-09-18 04:45:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Set acknowledg callback.
|
|
|
|
*
|
|
|
|
* See also igloo_logcore_acknowledge_t.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* core
|
|
|
|
* The core to configure.
|
|
|
|
* callback
|
|
|
|
* The callback to use.
|
|
|
|
* userdata
|
|
|
|
* The userdata pointer to pass to the callback.
|
|
|
|
*/
|
2019-09-18 04:04:50 -04:00
|
|
|
igloo_error_t igloo_logcore_set_acknowledge_cb(igloo_logcore_t *core, igloo_logcore_acknowledge_t callback, void *userdata);
|
2019-09-18 04:45:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Get a list of messages from the recent buffer.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* core
|
|
|
|
* The core to access.
|
|
|
|
* type
|
|
|
|
* Filter messages to messages of this type or NULL to not filter.
|
|
|
|
* filter
|
|
|
|
* Filter messages using this filter or NULL to not filter.
|
|
|
|
* limit
|
|
|
|
* Limit messages to this amount or -1 to not limit.
|
|
|
|
* id
|
|
|
|
* Return messages from the output with this ID or NULL to return from the global buffer.
|
|
|
|
* Returns:
|
|
|
|
* Prefiltered list of messages.
|
|
|
|
*/
|
2019-09-11 18:58:15 -04:00
|
|
|
igloo_list_t * igloo_logcore_get_recent(igloo_logcore_t *core, const igloo_ro_type_t *type, igloo_filter_t *filter, ssize_t limit, const char *id);
|
2019-09-18 04:45:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Get a list of messages from the askack buffer.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* core
|
|
|
|
* The core to access.
|
|
|
|
* type
|
|
|
|
* Filter messages to messages of this type or NULL to not filter.
|
|
|
|
* filter
|
|
|
|
* Filter messages using this filter or NULL to not filter.
|
|
|
|
* limit
|
|
|
|
* Limit messages to this amount or -1 to not limit.
|
|
|
|
* Returns:
|
|
|
|
* Prefiltered list of messages.
|
|
|
|
*/
|
2019-09-11 18:58:15 -04:00
|
|
|
igloo_list_t * igloo_logcore_get_askack(igloo_logcore_t *core, const igloo_ro_type_t *type, igloo_filter_t *filter, ssize_t limit);
|
2019-09-18 04:45:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Acknowledg a message in the askack buffer.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* core
|
|
|
|
* The core to access.
|
|
|
|
* object
|
|
|
|
* The message to acknowledg.
|
|
|
|
*/
|
2019-09-18 04:04:50 -04:00
|
|
|
igloo_error_t igloo_logcore_acknowledge(igloo_logcore_t *core, igloo_ro_t object);
|
2019-09-11 18:58:15 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* ! _LIBIGLOO__LOGCORE_H_ */
|