1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
* .. _asdf/log.h:
*
* Logging configuration and the logging API.
*
* libasdf emits diagnostic log messages associated with each open file. Every
* `asdf_file_t` carries a logging configuration (an `asdf_log_cfg_t`), which can
* be provided up front through the ``log`` field of `asdf_config_t` when opening
* a file with `asdf_open_ex`. Messages at or above the configured
* `asdf_log_level_t` are written to the configured stream (``stderr`` by
* default), optionally colorized and with a configurable set of prefix fields.
*
* If no level is set explicitly the default is taken from the ``ASDF_LOG_LEVEL``
* environment variable (one of ``NONE``, ``TRACE``, ``DEBUG``, ``INFO``,
* ``WARN``, ``ERROR``, or ``FATAL``, case-insensitive), falling back to
* ``WARN``.
*
* The library's own internal log statements are compiled in only when libasdf
* is built with logging enabled (the default; disable with ``-DENABLE_LOG=NO``
* under CMake or ``--disable-logging`` under the Autotools build). The public
* `asdf_file_log` function and `ASDF_LOG` macro are provided for extension
* authors who wish to emit messages through the same configuration; see
* :ref:`extensions`.
*/
//
/**
* Severity levels for log messages, in increasing order of severity
*
* A configured level acts as a threshold: only messages at that level or higher
* are emitted. `ASDF_LOG_NONE` disables logging entirely.
*/
typedef enum asdf_log_level_t;
/** The number of distinct `asdf_log_level_t` values */
/**
* Bitmask selecting every available log field
*
* See `asdf_log_field_t`.
*/
/**
* Flags selecting which fields the standard log formatter includes in each
* line
*
* Combine these as a bitmask in `asdf_log_cfg_t.fields`. The available flags
* are ``ASDF_LOG_FIELD_LEVEL`` (the severity), ``ASDF_LOG_FIELD_PACKAGE`` (the
* originating package/library), ``ASDF_LOG_FIELD_FILE`` and
* ``ASDF_LOG_FIELD_LINE`` (the source location), and ``ASDF_LOG_FIELD_MSG``
* (the message text itself). `ASDF_LOG_FIELD_ALL` selects them all.
*
* Log formatting is not otherwise customizable yet.
*/
typedef enum asdf_log_field_t;
/** A bitmask of `asdf_log_field_t` flags */
typedef uint64_t asdf_log_fields_t;
/**
* Per-file logging configuration
*
* Pass one of these as the ``log`` field of `asdf_config_t` to `asdf_open_ex`
* to control logging for a file. Any field left zero-initialized is filled in
* with a default: the stream defaults to ``stderr``, the level to the value of
* the ``ASDF_LOG_LEVEL`` environment variable (or ``ASDF_LOG_WARN``), and the
* fields to `ASDF_LOG_FIELD_ALL`.
*/
typedef struct asdf_log_cfg_t;
/* Forward declaration — full definition in <asdf/file.h> */
typedef struct asdf_file asdf_file_t;
/**
* Emit a log message associated with a file's logging configuration
*
* This is the public logging entry point for extension authors. The message
* is formatted like ``printf`` and emitted only if ``level`` meets the
* threshold configured for ``file``. In most cases the `ASDF_LOG` macro is
* more convenient, as it fills in the source file and line automatically.
*
* :param file: The `asdf_file_t *` whose log configuration to use; obtain it
* from an `asdf_value_t` with `asdf_value_file` if needed
* :param level: The severity of the message; see `asdf_log_level_t`
* :param src_file: Source file name to report (e.g. ``__FILE__``)
* :param lineno: Source line number to report (e.g. ``__LINE__``)
* :param fmt: A ``printf``-style format string
* :param ...: Arguments for ``fmt``
*/
ASDF_EXPORT void ;
/**
* Convenience wrapper around `asdf_file_log` that supplies ``__FILE__`` and
* ``__LINE__`` automatically
*
* Expands to nothing unless libasdf is built with logging enabled (the
* ``ASDF_LOG_ENABLED`` macro defined), so log statements can be left in place
* with no overhead in a non-logging build.
*
* :param file: The `asdf_file_t *` whose log configuration to use
* :param level: The severity of the message; see `asdf_log_level_t`
* :param ...: A ``printf``-style format string followed by its arguments
*/
/* ASDF_LOG_H */