--- l2.h.in 2001/11/03 22:51:36 1.14
+++ l2.h.in 2001/11/04 13:21:17 1.15
@@ -70,6 +70,7 @@
struct l2_stream_st;
struct l2_channel_st;
struct l2_handler_st;
+struct l2_env_st;
/* corresponding data types for data structures */
typedef union l2_context_un l2_context_t;
@@ -77,6 +78,7 @@
typedef struct l2_handler_st l2_handler_t;
typedef struct l2_stream_st l2_stream_t;
typedef struct l2_channel_st l2_channel_t;
+typedef struct l2_env_st l2_env_t;
/* list of logging levels (high to low priority; low to high amount of logging) */
typedef enum {
@@ -90,12 +92,16 @@
L2_LEVEL_TRACE = (1 << 6),
L2_LEVEL_DEBUG = (1 << 7)
} l2_level_t;
+
+/* macro describing a particular custom level */
#define L2_LEVEL_CUSTOM(n) (1 << (8+(n))
-#define L2_LEVEL_ALL ((1 << (8+9+1))-1)
-/* all levels from highest (PANIC) to and including a particular low level */
-#define L2_LEVEL_UPTO(level) \
- (((level)-1)|(level))
+/* macro describing all levels */
+#define L2_LEVEL_ALL ((1 << (8+9+1))-1)
+
+/* macr describing all levels from highest (PANIC)
+ to and including a particular low level */
+#define L2_LEVEL_UPTO(level) (((level)-1)|(level))
/* list of return values */
typedef enum {
@@ -155,6 +161,12 @@
L2_CHANNEL_OUTPUT
} l2_chtype_t;
+/* list of linking modes */
+typedef enum {
+ L2_LINK_CHILDS,
+ L2_LINK_SIBLINGS
+} l2_link_t;
+
/* channel handler specification structure */
struct l2_handler_st {
l2_chtype_t type;
@@ -192,37 +204,38 @@
extern l2_handler_t l2_handler_prefix;
extern l2_handler_t l2_handler_buffer;
+/* context operations */
+l2_result_t l2_env_create (l2_env_t **env);
+l2_result_t l2_env_destroy (l2_env_t *env);
+l2_result_t l2_env_levels (l2_env_t *env, unsigned int levelmask, unsigned int flushmask);
+l2_result_t l2_env_formatter (l2_env_t *env, char id, l2_formatter_t cb, l2_context_t *ctx);
+l2_result_t l2_env_errorinfo (l2_env_t *env, l2_result_t rv, const char *fmt, ...);
+char *l2_env_strerror (l2_env_t *env, l2_result_t rv);
+
/* channel operations */
-l2_channel_t *l2_channel_create (l2_handler_t *h);
+l2_result_t l2_channel_create (l2_channel_t **ch, l2_env_t *env, l2_handler_t *h);
+l2_result_t l2_channel_destroy (l2_channel_t *ch);
+l2_result_t l2_channel_levels (l2_channel_t *ch, unsigned int levelmask, unsigned int flushmask);
l2_result_t l2_channel_configure (l2_channel_t *ch, const char *fmt, ...);
l2_result_t l2_channel_open (l2_channel_t *ch);
l2_result_t l2_channel_write (l2_channel_t *ch, l2_level_t level, const char *buf, size_t bufsize);
l2_result_t l2_channel_flush (l2_channel_t *ch);
l2_result_t l2_channel_close (l2_channel_t *ch);
-l2_result_t l2_channel_destroy (l2_channel_t *ch);
-l2_result_t l2_channel_stack (l2_channel_t *ch, l2_channel_t *chTop);
+l2_result_t l2_channel_log (l2_channel_t *ch, l2_level_t level, const char *fmt, ...);
+l2_result_t l2_channel_vlog (l2_channel_t *ch, l2_level_t level, const char *fmt, va_list ap);
+l2_result_t l2_channel_link (l2_channel_t *ch, l2_link_t id, l2_channel_t *ch2, ...);
+l2_result_t l2_channel_unlink (l2_channel_t *ch);
l2_result_t l2_channel_upstream (l2_channel_t *ch, l2_channel_t **chU);
l2_result_t l2_channel_downstream (l2_channel_t *ch, l2_channel_t **chD);
l2_result_t l2_channel_type (l2_channel_t *ch, l2_chtype_t *type);
-l2_result_t l2_channel_errorinfo (l2_channel_t *ch, l2_result_t rv, const char *fmt, ...);
-char *l2_channel_strerror (l2_channel_t *ch, l2_result_t rv);
-
-/* stream operations */
-l2_stream_t *l2_stream_create (void);
-l2_result_t l2_stream_channel (l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask, unsigned int flushmask);
-l2_result_t l2_stream_formatter (l2_stream_t *st, char id, l2_formatter_t cb, l2_context_t *ctx);
-l2_result_t l2_stream_levels (l2_stream_t *st, unsigned int levelmask, unsigned int flushmask);
-l2_result_t l2_stream_log (l2_stream_t *st, l2_level_t level, const char *fmt, ...);
-l2_result_t l2_stream_vlog (l2_stream_t *st, l2_level_t level, const char *fmt, va_list ap);
-l2_result_t l2_stream_flush (l2_stream_t *st);
-l2_result_t l2_stream_destroy (l2_stream_t *st);
+l2_result_t l2_channel_env (l2_channel_t *ch, l2_env_t **env);
/* utility operations */
-l2_result_t l2_util_setparams (l2_param_t p[], const char *fmt, va_list ap);
-l2_result_t l2_util_l2s (char *string, size_t maxlen, int sep, unsigned int levelmask);
-l2_result_t l2_util_s2l (const char *string, size_t maxlen, int sep, unsigned int *levelmask);
-l2_result_t l2_util_fmt_string (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
-l2_result_t l2_util_fmt_dump (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
+l2_result_t l2_util_setparams (l2_param_t p[], const char *fmt, va_list ap);
+l2_result_t l2_util_l2s (char *string, size_t maxlen, int sep, unsigned int levelmask);
+l2_result_t l2_util_s2l (const char *string, size_t maxlen, int sep, unsigned int *levelmask);
+l2_result_t l2_util_fmt_string (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
+l2_result_t l2_util_fmt_dump (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
#endif /* __L2_H__ */
|