1 | /* -*- Mode: c; c-basic-offset: 2 -*- |
2 | * |
3 | * rdf_log.h - RDF logging interfaces |
4 | * |
5 | * Copyright (C) 2004-2008, David Beckett http://www.dajobe.org/ |
6 | * Copyright (C) 2004-2005, University of Bristol, UK http://www.bristol.ac.uk/ |
7 | * |
8 | * This package is Free Software and part of Redland http://librdf.org/ |
9 | * |
10 | * It is licensed under the following three licenses as alternatives: |
11 | * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version |
12 | * 2. GNU General Public License (GPL) V2 or any newer version |
13 | * 3. Apache License, V2.0 or any newer version |
14 | * |
15 | * You may not use this file except in compliance with at least one of |
16 | * the above three licenses. |
17 | * |
18 | * See LICENSE.html or LICENSE.txt at the top of this package for the |
19 | * complete terms and further detail along with the license texts for |
20 | * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. |
21 | * |
22 | * |
23 | */ |
24 | |
25 | |
26 | #ifndef LIBRDF_LOG_H |
27 | #define LIBRDF_LOG_H |
28 | |
29 | #ifdef __cplusplus |
30 | extern "C" { |
31 | #endif |
32 | |
33 | #include <raptor2.h> |
34 | |
35 | /** |
36 | * librdf_log_level: |
37 | * @LIBRDF_LOG_NONE: No level |
38 | * @LIBRDF_LOG_DEBUG: Debug. |
39 | * @LIBRDF_LOG_INFO: Information. |
40 | * @LIBRDF_LOG_WARN: Warning. |
41 | * @LIBRDF_LOG_ERROR: Recoverable error. Program can continue. |
42 | * @LIBRDF_LOG_FATAL: Fatal error. Program will abort if this is not caught. |
43 | * @LIBRDF_LOG_LAST: Internal, never returned. |
44 | * |
45 | * Indicates the level of the log message. |
46 | */ |
47 | typedef enum { |
48 | LIBRDF_LOG_NONE = 0, |
49 | LIBRDF_LOG_DEBUG, |
50 | LIBRDF_LOG_INFO, |
51 | LIBRDF_LOG_WARN, |
52 | LIBRDF_LOG_ERROR, |
53 | LIBRDF_LOG_FATAL, |
54 | LIBRDF_LOG_LAST=LIBRDF_LOG_FATAL |
55 | } librdf_log_level; |
56 | |
57 | |
58 | /** |
59 | * librdf_log_facility: |
60 | * @LIBRDF_FROM_CONCEPTS: Concepts |
61 | * @LIBRDF_FROM_DIGEST: Digest |
62 | * @LIBRDF_FROM_FILES: Files |
63 | * @LIBRDF_FROM_HASH: Hash |
64 | * @LIBRDF_FROM_INIT: Init |
65 | * @LIBRDF_FROM_ITERATOR: Iterator |
66 | * @LIBRDF_FROM_LIST: List |
67 | * @LIBRDF_FROM_MODEL: Model |
68 | * @LIBRDF_FROM_NODE: Node |
69 | * @LIBRDF_FROM_PARSER: Parser |
70 | * @LIBRDF_FROM_QUERY: Query |
71 | * @LIBRDF_FROM_SERIALIZER: Serializer |
72 | * @LIBRDF_FROM_STATEMENT: Statement |
73 | * @LIBRDF_FROM_STORAGE: Storage |
74 | * @LIBRDF_FROM_STREAM: Stream |
75 | * @LIBRDF_FROM_URI: URI |
76 | * @LIBRDF_FROM_UTF8: UTF8 |
77 | * @LIBRDF_FROM_MEMORY: Memory |
78 | * @LIBRDF_FROM_NONE: Associated with no part. |
79 | * @LIBRDF_FROM_RAPTOR: Raptor library (parser or serializer; Raptor 2.0.0+). |
80 | * @LIBRDF_FROM_LAST: Internal, never returned. |
81 | * |
82 | * Indicates the part of the system that generated the log message. |
83 | */ |
84 | typedef enum { |
85 | LIBRDF_FROM_NONE = 0, |
86 | LIBRDF_FROM_CONCEPTS, |
87 | LIBRDF_FROM_DIGEST, |
88 | LIBRDF_FROM_FILES, |
89 | LIBRDF_FROM_HASH, |
90 | LIBRDF_FROM_INIT, |
91 | LIBRDF_FROM_ITERATOR, |
92 | LIBRDF_FROM_LIST, |
93 | LIBRDF_FROM_MODEL, |
94 | LIBRDF_FROM_NODE, |
95 | LIBRDF_FROM_PARSER, |
96 | LIBRDF_FROM_QUERY, |
97 | LIBRDF_FROM_SERIALIZER, |
98 | LIBRDF_FROM_STATEMENT, |
99 | LIBRDF_FROM_STORAGE, |
100 | LIBRDF_FROM_STREAM, |
101 | LIBRDF_FROM_URI, |
102 | LIBRDF_FROM_UTF8, |
103 | LIBRDF_FROM_MEMORY, |
104 | LIBRDF_FROM_RAPTOR, |
105 | LIBRDF_FROM_LAST=LIBRDF_FROM_RAPTOR |
106 | } librdf_log_facility; |
107 | |
108 | |
109 | /** |
110 | * librdf_log_message: |
111 | * |
112 | * Structure for storing parts of a log message generated by Redland. |
113 | */ |
114 | typedef struct |
115 | { |
116 | int code; /* The error code */ |
117 | librdf_log_level level; |
118 | librdf_log_facility facility; |
119 | const char *message; |
120 | /* valid for certain facilities such as LIBRDF_FROM_PARSER */ |
121 | raptor_locator *locator; |
122 | } librdf_log_message; |
123 | |
124 | |
125 | /** |
126 | * librdf_log_level_func: |
127 | * @user_data: User data pointer |
128 | * @message: Log message. |
129 | * @arguments: Message arguments. |
130 | * |
131 | * Handler for one log level, for the warning and error levels ONLY. |
132 | * Used by #librdf_world_set_warning and #librdf_world_set_error. |
133 | * |
134 | * Return value: non-zero to indicate log message has been handled |
135 | */ |
136 | typedef int (REDLAND_CALLBACK_STDCALL *librdf_log_level_func)(void *user_data, const char *message, va_list arguments); |
137 | |
138 | /** |
139 | * librdf_log_func: |
140 | * @user_data: User data pointer |
141 | * @message: Log message structure pointer. |
142 | * |
143 | * Handler for all log levels. |
144 | * |
145 | * Return value: non-zero to indicate log message has been handled |
146 | */ |
147 | typedef int (REDLAND_CALLBACK_STDCALL *librdf_log_func)(void *user_data, librdf_log_message *message); |
148 | |
149 | #ifdef LIBRDF_INTERNAL |
150 | #include <rdf_log_internal.h> |
151 | #endif |
152 | |
153 | |
154 | /* log message accessors */ |
155 | REDLAND_API |
156 | int librdf_log_message_code(librdf_log_message *message); |
157 | REDLAND_API |
158 | librdf_log_level librdf_log_message_level(librdf_log_message *message); |
159 | REDLAND_API |
160 | librdf_log_facility librdf_log_message_facility(librdf_log_message *message); |
161 | REDLAND_API |
162 | const char * librdf_log_message_message(librdf_log_message *message); |
163 | REDLAND_API |
164 | raptor_locator* librdf_log_message_locator(librdf_log_message *message); |
165 | |
166 | /* logging functions */ |
167 | REDLAND_API |
168 | void librdf_log_simple(librdf_world* world, int code, librdf_log_level level, librdf_log_facility facility, void *locator, const char *message); |
169 | REDLAND_API |
170 | void librdf_log(librdf_world* world, int code, librdf_log_level level, librdf_log_facility facility, void *locator, const char *message, ...) REDLAND_PRINTF_FORMAT(6, 7); |
171 | |
172 | #ifdef __cplusplus |
173 | } |
174 | #endif |
175 | |
176 | #endif |
177 | |