1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
16
17 /*!
18 * ======== Log ========
19 * Event logging manager
20 *
21 * RTSC modules and the application code generate `{@link #Event Log_Event}`
22 * events by calling the `Log` module's functions. The `Log` module then
23 * passes those events to an `{@link ILogger}` instance assigned to the event
24 * originating module, specified by that module's configuration parameter
25 * `common$.logger`. `ILogger` instances handle events, usually converting
26 * events to `{@link #EventRec Log_EventRec}` records prior to recording,
27 * transmitting, or displaying them.
28 *
29 * All events generated by a target module are stored and displayed by an
30 * `ILogger`, examples of which are instances of
31 * `{@link LoggerBuf xdc.runtime.LoggerBuf}` or
32 * `{@link LoggerSys xdc.runtime.LoggerSys}`. At runtime, modules
33 * generate events through this module, rather than invoking directly their
34 * `ILogger`s. By doing so, modules can be configured to use different
35 * `ILogger` implementations without any changes to their source code.
36 *
37 * A logger instance can accept `Log` events from any module, but a module
38 * can put `Log` events to only one logger instance. There can be one or
39 * more logger instances in a system. All `Log` calls that are not in a
40 * module are controlled by the module `{@link Main xdc.runtime.Main}`.
41 * For example, top-level application code or any existing sources that
42 * simply call the `Log` or `Assert` methods implicitly use the logger
43 * associated with the `Main` module.
44 *
45 * The generation of a `Log` event is controlled by a module's diagnostics
46 * mask, which is described in details in `{@link Diags}`. Each `Log` event
47 * is associated with a mask. `Log` events are generated only when a
48 * particular bit is set in both the `Log` event mask
49 * and the module's diagnostics mask. For example, a `Log` event mask with
50 * the `{@link Diags#USER1 USER1}` bit set is generated only when the `USER1`
51 * bit is also set in the module's diagnostics mask.
52 *
53 * There are two ways to generate `Log` events:
54 *
55 * @p(blist)
56 * - `{@link #write8 Log_write()}`, which is tailored for module writers
57 * and takes full advantage of the XDC configuration model. For example,
58 * the message string associated with the `Log` event need not be a part of
59 * the final application, significantly reducing the "footprint overhead"
60 * of embedding diagnostics in deployed systems. The `Log_write[0-8]()`
61 * functions allow up to 8 values to be passed to the logger. They expect
62 * the logger to handle any formatting. A `Log` event type allows you to
63 * specify the type of event.
64 * - `{@link #print6 Log_print()}`, which is designed for arbitrary C code.
65 * The `Log_print[0-6]()` functions allow up to 6 values to be passed along
66 * with a printf-like format string to the logger. They handle printf-style
67 * formatting.
68 * @p
69 *
70 * Both functions are controlled by the module's diagnostics mask. Their
71 * storage or output is defined by the logger that is assigned to the
72 * module that calls the `Log` methods or to the
73 * `{@link Main xdc.runtime.Main}` module if the caller is not part of a
74 * module.
75 *
76 * The `Log` function call sites are implemented in such a way that an
77 * optimizer can completely eliminate `Log` code from the program if the
78 * `Log` functions have been permanently disabled at configuration time. If
79 * the `Log` functions are permanently turned on at configuration time,
80 * then the optimizer can eliminate all runtime conditional checking and
81 * simply invoke the `Log` functions directly. Runtime checking is performed
82 * only when the `Log` functions are configured to be runtime modifiable.
83 *
84 * The Log calls can also be completely removed by defining the symbol
85 * `xdc_runtime_Log_DISABLE_ALL`. This can be done on the compile line, e.g.
86 * `-Dxdc_runtime_Log_DISABLE_ALL`. This will completely remove the `Log`
87 * statements from any code compiled with this flag, regardless of the
88 * application's logging configuration or your compiler's optimization
89 * settings.
90 *
91 * It is also possible to remove all logging except for
92 * `{@link #error Log_error}`, `{@link #warning Log_warning}`, or
93 * `{@link #info Log_info}` statements. This is done by first defining
94 * `xdc_runtime_Log_DISABLE_ALL`, followed by defining one or more of the
95 * symbols below to leave that type of logging enabled:
96 * @p(blist)
97 * - `xdc_runtime_Log_ENABLE_ERROR`
98 * - `xdc_runtime_Log_ENABLE_WARNING`
99 * - `xdc_runtime_Log_ENABLE_INFO`
100 * @p
101 * For example, to disable all `Log` statements except for `Log_error`, add
102 * the following to the compile line:
103 * @p(code)
104 * -Dxdc_runtime_Log_DISABLE_ALL -Dxdc_runtime_Log_ENABLE_ERROR
105 * @p
106 *
107 * @a(Examples)
108 * Example 1: The following example defines a `Log` event, uses that `Log`
109 * event in a module, and configures the program to generate the `Log`
110 * event. In this example, both `USER1` and `USER2` bits are set in the
111 * event mask. This means that if either bit is set in the module's
112 * diagnostics mask, then the `Log` event will be generated.
113 *
114 * This is a part of the XDC specification file for the `Mod` module
115 * (Mod.xdc):
116 *
117 * @p(code)
118 * import xdc.runtime.Diags;
119 * import xdc.runtime.Log;
120 *
121 * config Log.Event L_someEvent = {
122 * mask: Diags.USER1 | Diags.USER2,
123 * level: Diags.LEVEL1,
124 * msg: "my log event message, arg1: 0x%x, arg2: 0x%x"
125 * };
126 * @p
127 *
128 * This is a part of the C code implementation of the Mod module:
129 *
130 * @p(code)
131 * #include <xdc/runtime/Log.h>
132 * UInt x, y;
133 *
134 * Log_write2(Mod_L_someEvent, (IArg)x, (IArg)y);
135 * @p
136 *
137 * The following configuration script demonstrates how the application might
138 * control the `Log` statements embedded in the `Mod` module at configuration
139 * time. In this case, the configuration script arranges for the `Log`
140 * statements within the `Mod` module (shown above) to always generate events.
141 * Without these configuration statements, no `Log` events would be generated
142 * by this module.
143 *
144 * This is part of the XDC configuration file for the application:
145 *
146 * @p(code)
147 * var Diags = xdc.useModule('xdc.runtime.Diags');
148 * var LoggerSys = xdc.useModule('xdc.runtime.LoggerSys');
149 * var Mod = xdc.useModule('my.pkg.Mod');
150 * Mod.common$.diags_USER1 = Diags.ALWAYS_ON;
151 * Mod.common$.logger = LoggerSys.create();
152 * @p
153 *
154 * @p(html)
155 * <hr />
156 * @p
157 *
158 * Example 2: The following XDC configuration statements turn on enter
159 * and exit logging at configuration time for a module. Without any other
160 * changes in the runtime code, every time a module `Mod`'s function is
161 * being called or exits, an event will be logged.
162 *
163 * @p(code)
164 * var Diags = xdc.useModule('xdc.runtime.Diags');
165 * var Mod = xdc.useModule('my.pkg.Mod');
166 *
167 * Mod.common$.diags_ENTER = Diags.ALWAYS_ON;
168 * Mod.common$.diags_EXIT = Diags.ALWAYS_ON;
169 * @p
170 *
171 * @p(html)
172 * <hr />
173 * @p
174 *
175 * Example 3: The following example configures a module to support enter and
176 * exit logging, but defers the actual activation and deactivation of the
177 * logging until runtime. See the `{@link Diags#setMask Diags_setMask()}`
178 * function for details on specifying the control string.
179 *
180 * This is a part of the XDC configuration file for the application:
181 *
182 * @p(code)
183 * var Diags = xdc.useModule('xdc.runtime.Diags');
184 * var Mod = xdc.useModule('my.pkg.Mod');
185 *
186 * Mod.common$.diags_ENTER = Diags.RUNTIME_OFF;
187 * Mod.common$.diags_EXIT = Diags.RUNTIME_OFF;
188 * @p
189 *
190 * This is a part of the C code for the application:
191 *
192 * @p(code)
193 * // turn on enter and exit logging in the module
194 * Diags_setMask("my.pkg.Mod+EX");
195 *
196 * // turn off enter and exit logging in the module
197 * Diags_setMask("my.pkg.Mod-EX");
198 * @p
199 */
200
201 @CustomHeader
202
203 module Log {
204
205 /*!
206 * ======== NUMARGS ========
207 * Maximum number of arguments supported in `Log` events.
208 */
209 const Int NUMARGS = 8;
210
211 /*!
212 * ======== PRINTFID ========
213 * The `EventId` for `Log_print()` events
214 */
215 const EventId PRINTFID = 0;
216
217 /*!
218 * ======== EventDesc ========
219 * `Log` event descriptor
220 *
221 * Each `Log` event is defined by a `Log` event descriptor.
222 *
223 * The `mask` defines which bits in the module's diagnostics mask
224 * enable this `Log` event. Events "posted" via `Log_write` are only
225 * written to the underlying logger if one of the mask's bits matches
226 * the caller's module diagnostics settings (see
227 * `{@link xdc.runtime.Types#common$}`).
228 *
229 * The 'level' defines the event level of the event. While the diags
230 * bits selected in the 'mask' signify the "category" of the event (e.g.
231 * Entry/Exit, Analysis, Info), the 'level' field allows you to assign
232 * a "priority" or "detail level" to the event relative to other events in
233 * that category. There are four event levels defined by
234 * '{@link xdc.runtime.Diags#EventLevel}'.
235 *
236 * Filtering of events by level is handled by the ILogger implementation.
237 * ILogger implementations which also implement the {@link IFilterLogger}
238 * interface support filtering of events based on priority level.
239 *
240 * Specifying an event level is optional. Events that don't specify a
241 * level will receive Diags.LEVEL1 by default, making them the highest
242 * priority and ensuring that they will not inadvertently be filtered out
243 * by level-based filtering.
244 *
245 * The `msg` defines a printf style format string that defines how to
246 * render the arguments passed along the event in a `Log_write` call.
247 * For a description of the allowable format strings see
248 * `{@link #print6}`.
249 *
250 * @see #write8
251 * @see #print6
252 */
253 metaonly struct EventDesc {
254 Diags.Mask mask; /*! event enable mask */
255 Diags.EventLevel level; /*! event level relative to other events */
256 String msg; /*! event "printf" message format string */
257 };
258
259 /*!
260 * ======== EventRec ========
261 * The target representation of a recorded event
262 *
263 * This structure defines how events are recorded on the target.
264 */
265 struct EventRec {
266 Types.Timestamp64 tstamp; /*! time event was written */
267 Bits32 serial; /*! serial number of event */
268 Types.Event evt; /*! target encoding of an Event */
269 IArg arg[NUMARGS]; /*! arguments passed via Log_write/print */
270 }
271
272 /*!
273 * ======== Event ========
274 * `Log` event type
275 *
276 * An `Event` is represented on the target as a 32-bit value that can
277 * be decoded offline to recover the `Event` information defined in
278 * a corresponding metaonly `EventDesc`. In addition, `Event`s may be
279 * decoded at runtime via methods provided in this module; see
280 * `{@link #getMask}` and `{@link #getEventId}`.
281 *
282 * When an event is "raised" a `{@link Types#Event Types_Event}` is
283 * created which has the same event ID as the `Log_Event` but also
284 * encodes the module ID of the caller. This new event is passed to
285 * the underlying `{@link ILogger}` module along with any arguments
286 * associated with the event.
287 *
288 * @see #getMask
289 * @see #getEventId
290 */
291 @Encoded typedef EventDesc Event;
292
293 /*!
294 * ======== EventId ========
295 * Unique ID embedded in each `{@link #Event}`
296 *
297 * This ID must be used to compare two `Event`s for equality. Event
298 * ids are not guaranteed to remain constant between different
299 * configurations of an application. For example, adding a module
300 * may cause the event ids of another module to change.
301 *
302 * However, event ids declared by a module are guaranteed to be
303 * consecutive values starting from the first declared
304 * `{@link #Event Log_Event}` and increasing to the last declared
305 * event. As a result, clients of a module can efficiently test ranges
306 * of events and modules can add new events, such as internal trace
307 * events, without breaking clients; simply be careful to add new events
308 * after any existing events in you module's `.xdc` specification.
309 *
310 * @see #getEventId
311 * @see #Event
312 */
313 typedef Types.RopeId EventId;
314
315 /*!
316 * ======== L_construct ========
317 * Lifecycle event posted when an instance is constructed
318 */
319 config Log.Event L_construct = {
320 mask: Diags.LIFECYCLE,
321 msg: "<-- construct: %p('%s')"
322 };
323
324 /*!
325 * ======== L_create ========
326 * Lifecycle event posted when an instance is created
327 */
328 config Log.Event L_create = {
329 mask: Diags.LIFECYCLE,
330 msg: "<-- create: %p('%s')"
331 };
332
333 /*!
334 * ======== L_destruct ========
335 * Lifecycle event posted when an instance is destructed
336 */
337 config Log.Event L_destruct = {
338 mask: Diags.LIFECYCLE,
339 msg: "--> destruct: (%p)"
340 };
341
342 /*!
343 * ======== L_delete ========
344 * Lifecycle event posted when an instance is deleted
345 */
346 config Log.Event L_delete = {
347 mask: Diags.LIFECYCLE,
348 msg: "--> delete: (%p)"
349 };
350
351 /*!
352 * ======== L_error ========
353 * Error event posted by Log_errorX API
354 *
355 * This event is marked as a STATUS event and given the priority level
356 * of ERROR.
357 *
358 * This event prints the Log call site (%$F) and a format string (%$S)
359 * which is recursively formatted with any additional arguments.
360 */
361 config Log.Event L_error = {
362 mask: Diags.STATUS,
363 level: Diags.ERROR,
364 msg: "ERROR: %$F%$S"
365 };
366
367 /*!
368 * ======== L_warning ========
369 * Warning event posted by Log_warningX API
370 *
371 * This event is marked as a STATUS event and given the priority level of
372 * WARNING.
373 *
374 * This event prints the Log call site (%$F) and a format string (%$S)
375 * which is recursively formatted with any addition arguments.
376 */
377 config xdc.runtime.Log.Event L_warning = {
378 mask: Diags.STATUS,
379 level: Diags.WARNING,
380 msg: "WARNING: %$F%$S"
381 };
382
383 /*!
384 * ======== L_info ========
385 * Info event posted by Log_infoX API
386 *
387 * This event is marked as an INFO event. The event priority is not
388 * specified in the event definition. Rather, it is specified as an
389 * argument to the Log_infoX APIs.
390 *
391 * This event prints the Log call site (%$F) and a format string (%$S)
392 * which is recursively formatted with any addition arguments.
393 */
394 config xdc.runtime.Log.Event L_info = {
395 mask: Diags.INFO,
396 msg: "%$F%$S"
397 };
398
399 /*!
400 * ======== L_start ========
401 * Benchmark event used to log the start of an operation
402 * @_nodoc
403 *
404 * @a(Example)
405 * The following C code shows how to log a simple
406 * benchmark 'start' event along with a user-specified
407 * format string describing the event.
408 *
409 * @p(code)
410 * #include <xdc/runtime/Log.h>
411 * ...
412 * Log_write2(Log_L_start, (IArg)"My benchmark event", (IArg)myUniqueId);
413 * Log_write2(Log_L_stop, (IArg)"My benchmark event", (IArg)myUniqueId);
414 * @p
415 *
416 * @param(fmt) a constant string that provides format specifiers for
417 * up to 6 additional parameters
418 * @param(id) a unique ID used to match benchmark start and stop
419 * events
420 */
421 config xdc.runtime.Log.Event L_start = {
422 mask: Diags.ANALYSIS,
423 msg: "Start: %$S"};
424
425 /*!
426 * ======== L_stop ========
427 * Benchmark event used to log the end of an operation
428 * @_nodoc
429 *
430 * @a(Example)
431 * The following C code shows how to log a simple
432 * benchmark 'stop' event along with a user-specified
433 * format string describing the event.
434 *
435 * @p(code)
436 * #include <xdc/runtime/Log.h>
437 * ...
438 * Log_write2(Log_L_start, (IArg)"My benchmark event", (IArg)myUniqueId);
439 * Log_write2(Log_L_stop, (IArg)"My benchmark event", (IArg)myUniqueId);
440 * @p
441 *
442 * @param(fmt) a constant string that provides format specifiers for
443 * up to 6 additional parameters
444 * @param(id) a unique ID used to match benchmark start and stop
445 * events
446 */
447 config xdc.runtime.Log.Event L_stop = {
448 mask: Diags.ANALYSIS,
449 msg: "Stop: %$S"};
450
451 /*!
452 * ======== L_startInstance ========
453 * Benchmark event used to log the start of an operation instance
454 * @_nodoc
455 *
456 * Event parameter provides instance data to differentiate
457 * between multiple instances that can run in parallel.
458 *
459 * @a(Example)
460 * The following C code shows how to log a benchmark
461 * 'startInstance' event along with a user-specified
462 * instance identifier and a format string describing the event.
463 *
464 * @p(code)
465 * #include <xdc/runtime/Log.h>
466 * ...
467 * Log_write3(Log_L_startInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
468 * ...
469 * Log_write3(Log_L_stopInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
470 * @p
471 *
472 * @param(fmt) a constant string that provides format specifiers for
473 * up to 6 additional parameters
474 * @param(id) a unique ID used to match benchmark start and stop
475 * events
476 * @param(instId) a unique instance ID that can be used to match
477 * instance events
478 */
479 config xdc.runtime.Log.Event L_startInstance = {
480 mask: Diags.ANALYSIS,
481 msg: "StartInstance: %$S"
482 };
483
484 /*!
485 * ======== L_stopInstance ========
486 * Benchmark event used to log the end of an operation instance
487 * @_nodoc
488 *
489 * Event parameter provides instance data to differentiate
490 * between multiple instances that can run in parallel.
491 *
492 * @a(Example)
493 * The following C code shows how to log a benchmark
494 * 'stopInstance' event along with a user-specified
495 * instance identifier and a format string describing the event.
496 *
497 * @p(code)
498 * #include <xdc/runtime/Log.h>
499 * ...
500 * Log_write3(Log_L_startInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
501 * ...
502 * Log_write3(Log_L_stopInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
503 * @p
504 *
505 * @param(fmt) a constant string that provides format specifiers for
506 * up to 6 additional parameters
507 * @param(id) a unique ID used to match benchmark start and stop
508 * events
509 * @param(instId) a unique instance ID that can be used to match
510 * instance events
511 */
512 config xdc.runtime.Log.Event L_stopInstance = {
513 mask: Diags.ANALYSIS,
514 msg: "StopInstance: %$S"
515 };
516
517 /*!
518 * ======== getMask ========
519 * Get the `Diags` mask for the specified (encoded) event
520 *
521 * @param(evt) the `Log` event encoding a mask and event ID
522 *
523 * @a(returns) `Diags` mask for the specified event
524 */
525 @Macro Diags.Mask getMask(Event evt);
526
527 /*!
528 * ======== getRope ========
529 * Get RopeId of the Event.msg for the specified (encoded) event
530 * @_nodoc
531 */
532 @Macro Text.RopeId getRope(Event evt);
533
534 /*!
535 * ======== getEventId ========
536 * Get event ID of the specified (encoded) event
537 *
538 * This method is used to compare "known" `Log` events with
539 * "raised" `{@link Types#Event Types_Event}`.
540 *
541 * @param(evt) the `Log` event encoding a mask and event ID
542 *
543 * @a(returns) event ID of the specified event
544 *
545 * @see Types#getEventId
546 */
547 @Macro EventId getEventId(Event evt);
548
549 /*!
550 * ======== print0 ========
551 * Generate a `Log` "print event" with 0 arguments
552 *
553 * @see #print6
554 */
555 @Macro Void print0(Diags.Mask mask, String fmt);
556
557 /*!
558 * ======== print1 ========
559 * Generate a `Log` "print event" with 1 argument
560 *
561 * @see #print6
562 */
563 @Macro Void print1(Diags.Mask mask, String fmt, IArg a1);
564
565 /*!
566 * ======== print2 ========
567 * Generate a `Log` "print event" with 2 arguments
568 *
569 * @see #print6
570 */
571 @Macro Void print2(Diags.Mask mask, String fmt, IArg a1, IArg a2);
572
573 /*!
574 * ======== print3 ========
575 * Generate a `Log` "print event" with 3 arguments
576 *
577 * @see #print6
578 */
579 @Macro Void print3(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3);
580
581 /*!
582 * ======== print4 ========
583 * Generate a `Log` "print event" with 4 arguments
584 *
585 * @see #print6
586 */
587 @Macro Void print4(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3,
588 IArg a4);
589
590 /*!
591 * ======== print5 ========
592 * Generate a `Log` "print event" with 5 arguments
593 *
594 * @see #print6
595 */
596 @Macro Void print5(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3,
597 IArg a4, IArg a5);
598
599 /*!
600 * ======== print6 ========
601 * Generate a `Log` "print event" with 6 arguments
602 *
603 * As a convenience to C (as well as assembly language) programmers,
604 * the `Log` module provides a variation of the ever-popular `printf`
605 * function.
606 * The `print[0-6]` functions generate a `Log` "print event" and route
607 * it to the current module's logger.
608 *
609 * The arguments passed to `print[0-6]` may be characters, integers,
610 * strings, or pointers. However, because the declared type of the
611 * arguments is `{@link xdc IArg}`, all pointer arguments must be cast
612 * to an `IArg` type. `IArg` is an integral type large enough to hold
613 * any pointer or an `int`. So, casting a pointer to an `IArg` does
614 * not cause any loss of information and C's normal integer conversions
615 * make the cast unnecessary for integral arguments.
616 *
617 * The format string can use the following conversion characters.
618 * However, it is important to recall that all arguments referenced by
619 * these conversion characters have been converted to an `IArg`
620 * prior to conversion; so, the use of "length modifiers" should be
621 * avoided.
622 *
623 * @p(code)
624 * Conversion Character Description
625 * ------------------------------------------------
626 * %c Character
627 * %d Signed integer
628 * %u Unsigned integer
629 * %x Unsigned hexadecimal integer
630 * %o Unsigned octal integer
631 * %s Character string
632 * %p Pointer
633 * %f Single precision floating point (float)
634 * @p
635 *
636 * Format strings, while very convenient, are a well known source of
637 * portability problems: each format specification must precisely match
638 * the types of the arguments passed. Underlying "printf" functions use
639 * the format string to determine how far to advance through their
640 * argument list. For targets where pointer types and integers are the
641 * same size there are no problems. However, suppose a target's pointer
642 * type is larger than its integer type. In this case, because integer
643 * arguments are widened to be of type `IArg`, a format specification of
644 * "%d" causes an underlying `printf()` implementation to read the
645 * extended part of the integer argument as part of the next argument(!).
646 *
647 * To get around this problem and still allow the use of "natural"
648 * format specifications (e.g., `%d` and `%x` with optional width
649 * specifications), `{@link System#aprintf()}` is used which assumes
650 * that all arguments have been widened to be of type `IArg`.
651 *
652 * See `{@link System#printf}` for complete details.
653 *
654 * The `%f` format specifier is used to print a single precision float
655 * value. Note that `%f` assumes that sizeof(Float) <= sizeof(IArg).
656 * Most clients that interpret float values expect that they are
657 * represented in IEEE 754 floating point format. Therefore, it is
658 * recommended that the float values be converted into that format prior
659 * to supplying the values to `Log` functions in cases where targets do
660 * not generate the float values in IEEE 754 floating point format by
661 * default.
662 *
663 * The first argument to a `Log_print` call is the diags category to be
664 * associated with the event.
665 *
666 * It is also possible to associate an event level with the event to
667 * enable filtering of events based on event level. Conceptually, it is
668 * best to regard the event level as completely separate from the event's
669 * diags category; however, the priority value actually occupies a part
670 * of the diags mask. For this reason, it is possible to specify an event
671 * level by OR'ing the level with the diags mask. For example, to print
672 * an `Diags_INFO` event of `Diags_LEVEL2`, you'd simply write:
673 * (Diags_INFO | Diags_LEVEL2)
674 *
675 * Specifying an event level is optional. `Log_print` calls which do not
676 * specify a level will receive the highest priority by default.
677 *
678 * @param(mask) enable bits and optional detail level for this event
679 * @param(fmt) a `printf` style format string
680 * @param(a1) value for first format conversion character
681 * @param(a2) value for second format conversion character
682 * @param(a3) value for third format conversion character
683 * @param(a4) value for fourth format conversion character
684 * @param(a5) value for fifth format conversion character
685 * @param(a6) value for sixth format conversion character
686 *
687 * @a(Examples)
688 * The following example demonstrates a typical usage.
689 * @p(code)
690 * String list[];
691 * UInt i;
692 *
693 * Log_print2(Diags_USER2, "list[%u] = %s\n", i, (IArg)list[i]);
694 * @p
695 * Note that the `IArg` cast above is only necessary for pointer
696 * arguments; C's normal parameter conversions implicitly convert
697 * integral arguments.
698 *
699 * To simplify the conversion from `float` arguments to `IArg`,
700 * the standard header `xdc/std.h` provides a macro, named floatToArg(),
701 * to do this conversion in a type safe manner. So, the following
702 * statement will print "`float = 2.3456`":
703 * @p(code)
704 * Log_print1(Diags_USER1, "float = %f", floatToArg(2.34567));
705 * @p
706 *
707 * Note that, if you are formatting events on the target, you must
708 * also add support for floating point to ASCII conversion to
709 * `{@link System#printf}`; for more information, see the
710 * `{@link System#extendedFormats}` reference documenation. For example:
711 * @p(code)
712 * var System = xdc.useModule('xdc.runtime.System');
713 * System.extendedFormats = "%f";
714 * @p
715 */
716 @Macro Void print6(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3,
717 IArg a4, IArg a5, IArg a6);
718
719 /*!
720 * ======== error0 ========
721 * Generate a `Log` "error event" with 0 arguments
722 *
723 * @see #error5
724 */
725 @Macro Void error0(String fmt);
726
727 /*!
728 * ======== error1 ========
729 * Generate a `Log` "error event" with 1 argument
730 *
731 * @see #error5
732 */
733 @Macro Void error1(String fmt, IArg a1);
734
735 /*!
736 * ======== error2 ========
737 * Generate a `Log` "error event" with 2 arguments
738 *
739 * @see #error5
740 */
741 @Macro Void error2(String fmt, IArg a1, IArg a2);
742
743 /*!
744 * ======== error3 ========
745 * Generate a `Log` "error event" with 3 arguments
746 *
747 * @see #error5
748 */
749 @Macro Void error3(String fmt, IArg a1, IArg a2, IArg a3);
750
751 /*!
752 * ======== error4 ========
753 * Generate a `Log` "error event" with 4 arguments
754 *
755 * @see #error5
756 */
757 @Macro Void error4(String fmt, IArg a1, IArg a2, IArg a3,
758 IArg a4);
759
760 /*!
761 * ======== error5 ========
762 * Generate a `Log` "error event" with 5 arguments
763 *
764 * The Log_error APIs are intended to allow users to easily log error
765 * events in their code. Similar to the Log_print APIs, Log_error does not
766 * require that you define an event. You simply pass an informative error
767 * string which can optionally be formatted with additional arguments. The
768 * error is logged with the predefined event {@link #L_error}.
769 *
770 * Log_error prepends a string to the message which identifies it as an
771 * ERROR and specifies the filename and line number of the Log_error call
772 * site. A simple example:
773 *
774 * @p(code)
775 * Log_error0("Invalid argument");
776 * @p
777 * This event will be formatted as (assuming that the above call was line
778 * 35 of "MyCode.c")
779 * @p(code)
780 * ERROR at "MyCode.c", line 35: Invalid argument
781 * @p
782 *
783 * Users may provide additional information in the error event, such as
784 * a predefined error code or details of the error. These additional
785 * values will be used to format the string passed to Log_error.
786 * @see #print6 for information about format strings.
787 *
788 * Log_error does not use a variable length argument list--you must call
789 * the appropriate Log_errorX API based on the number of arguments.
790 *
791 * @param(fmt) a reference to a constant error string / fmt string
792 * @param(a1) value for an additional parameter (e.g. an error code)
793 * @param(a2) value for an additional parameter
794 * @param(a3) value for an additional parameter
795 * @param(a4) value for an additional parameter
796 * @param(a5) value for an additional parameter
797 *
798 * @a(Examples)
799 * The following example demonstrates a typical usage.
800 * @p(code)
801 * Int myArg;
802 *
803 * Log_error1("Invalid argument: %d", myArg);
804 * @p
805 * The above event is formatted as, for example:
806 * @p(code)
807 * ERROR: "MyCode.c", line 35: Invalid argument: -1
808 * @p
809 */
810 @Macro Void error5(String fmt, IArg a1, IArg a2, IArg a3,
811 IArg a4, IArg a5);
812
813 /*!
814 * ======== warning0 ========
815 * Generate a `Log` "warning event" with 0 arguments
816 *
817 * @see #warning5
818 */
819 @Macro Void warning0(String fmt);
820
821 /*!
822 * ======== warning1 ========
823 * Generate a `Log` "warning event" with 1 argument
824 *
825 * @see #warning5
826 */
827 @Macro Void warning1(String fmt, IArg a1);
828
829 /*!
830 * ======== warning2 ========
831 * Generate a `Log` "warning event" with 2 arguments
832 *
833 * @see #warning5
834 */
835 @Macro Void warning2(String fmt, IArg a1, IArg a2);
836
837 /*!
838 * ======== warning3 ========
839 * Generate a `Log` "warning event" with 3 arguments
840 *
841 * @see #warning5
842 */
843 @Macro Void warning3(String fmt, IArg a1, IArg a2, IArg a3);
844
845 /*!
846 * ======== warning4 ========
847 * Generate a `Log` "warning event" with 4 arguments
848 *
849 * @see #warning5
850 */
851 @Macro Void warning4(String fmt, IArg a1, IArg a2, IArg a3,
852 IArg a4);
853
854 /*!
855 * ======== warning5 ========
856 * Generate a `Log` "warning event" with 5 arguments
857 *
858 * The Log_warning APIs provide the same features as the Log_error APIs,
859 * but are used to specifically log "warning" events.
860 * @see #error5
861 *
862 * The Log_warning APIs are equivalent to the Log_error APIs except that
863 * they use the predefined {@link #L_warning} event. Log_warning prepends
864 * a string to the message which identifies it as a WARNING and specifies
865 * the filename and line number of the Log_warning call site.
866 *
867 * @param(fmt) reference to a constant warning string / fmt string
868 * @param(a1) value for an additional parameter (e.g. a warning code)
869 * @param(a2) value for an additional parameter
870 * @param(a3) value for an additional parameter
871 * @param(a4) value for an additional parameter
872 * @param(a5) value for an additional parameter
873 *
874 * @a(Examples)
875 * The following example demonstrates a typical usage.
876 * @p(code)
877 * Int myArg;
878 *
879 * Log_warning1("Value may be too high: %d", myArg);
880 * @p
881 * The above event is formatted as:
882 * @p(code)
883 * WARNING: "MyCode.c", line 50: Value may be too high: 4096
884 * @p
885 */
886 @Macro Void warning5(String fmt, IArg a1, IArg a2, IArg a3,
887 IArg a4, IArg a5);
888
889 /*!
890 * ======== info0 ========
891 * Generate a `Log` "info event" with 0 arguments
892 *
893 * @see #info5
894 */
895 @Macro Void info0(String fmt);
896
897 /*!
898 * ======== info1 ========
899 * Generate a `Log` "info event" with 1 argument
900 *
901 * @see #info5
902 */
903 @Macro Void info1(String fmt, IArg a1);
904
905 /*!
906 * ======== info2 ========
907 * Generate a `Log` "info event" with 2 arguments
908 *
909 * @see #info5
910 */
911 @Macro Void info2(String fmt, IArg a1, IArg a2);
912
913 /*!
914 * ======== info3 ========
915 * Generate a `Log` "info event" with 3 arguments
916 *
917 * @see #info5
918 */
919 @Macro Void info3(String fmt, IArg a1, IArg a2, IArg a3);
920
921 /*!
922 * ======== info4 ========
923 * Generate a `Log` "info event" with 4 arguments
924 *
925 * @see #info5
926 */
927 @Macro Void info4(String fmt, IArg a1, IArg a2, IArg a3, IArg a4);
928
929 /*!
930 * ======== info5 ========
931 * Generate a `Log` "info event" with 5 arguments
932 *
933 * The Log_info APIs are provided for easily logging generic
934 * "informational" events with call site information. They are similar to
935 * the Log_print APIs in that they do not require you to define an event--
936 * you simply pass an informative printf-style string which can optionally
937 * be formatted with additional arguments. The info record is logged with
938 * the predefined event '{@link #L_info}'.
939 *
940 * The Log_info APIs log the {@link #L_info} event which uses the 'INFO'
941 * diags category. They do not allow you to specify an event priority.
942 *
943 * Log_info prepends the filename and line number of the call site to the
944 * message.
945 *
946 * @param(fmt) reference to a constant event string / fmt string
947 * @param(a1) value for an additional parameter (e.g. an event code)
948 * @param(a2) value for an additional parameter
949 * @param(a3) value for an additional parameter
950 * @param(a4) value for an additional parameter
951 * @param(a5) value for an additional parameter
952 *
953 * @a(Examples)
954 * The following example demonstrates a typical usage.
955 * @p(code)
956 * Int load;
957 *
958 * Log_info1("Current load: %d", load);
959 * @p
960 * The above event is formatted as, for example:
961 * @p(code)
962 * "MyCode.c", line 15: Current load: 25
963 * @p
964 */
965 @Macro Void info5(String fmt, IArg a1, IArg a2, IArg a3, IArg a4, IArg a5);
966
967 /*!
968 * ======== put0 ========
969 * Unconditionally put the specified Log event with 0 arguments
970 *
971 * @see #put8
972 */
973 @Macro Void put0(Log.Event evt, Types.ModuleId mid);
974
975 /*!
976 * ======== put1 ========
977 * Unconditionally put the specified Log event and 1 argument
978 *
979 * @see #put8
980 */
981 @Macro Void put1(Log.Event evt, Types.ModuleId mid, IArg a1);
982
983 /*!
984 * ======== put2 ========
985 * Unconditionally put the specified Log event and 2 arguments
986 *
987 * @see #put8
988 */
989 @Macro Void put2(Log.Event evt, Types.ModuleId mid, IArg a1, IArg a2);
990
991 /*!
992 * ======== put4 ========
993 * Unconditionally put the specified Log event and 4 arguments
994 *
995 * @see #put8
996 */
997 @Macro Void put4(Log.Event evt, Types.ModuleId mid, IArg a1, IArg a2,
998 IArg a3, IArg a4);
999
1000 /*!
1001 * ======== put8 ========
1002 * Unconditionally put the specified Log event and 8 arguments
1003 *
1004 * This method unconditionally puts the specified `{@link Event}`
1005 * `evt` into the log. The `{@link Types#ModuleId}` `mid` should be the
1006 * module ID of the module which is putting the event.
1007 *
1008 * @param(evt) the Log event to put into the log
1009 * @param(mid) module ID of the module putting the event
1010 * @param(a1) value for first format conversion character
1011 * @param(a2) value for second format conversion character
1012 * @param(a3) value for third format conversion character
1013 * @param(a4) value for fourth format conversion character
1014 * @param(a5) value for fifth format conversion character
1015 * @param(a6) value for sixth format conversion character
1016 * @param(a7) value for seventh format conversion character
1017 * @param(a8) value for eighth format conversion character
1018 */
1019 @Macro Void put8(Log.Event evt, Types.ModuleId mid, IArg a1, IArg a2,
1020 IArg a3, IArg a4, IArg a5, IArg a6, IArg a7, IArg a8);
1021
1022 /*!
1023 * ======== write0 ========
1024 * Generate a `Log` event with 0 arguments
1025 *
1026 * @see #write8
1027 */
1028 @Macro Void write0(Event evt);
1029
1030 /*!
1031 * ======== write1 ========
1032 * Generate a `Log` event with 1 argument
1033 *
1034 * @see #write8
1035 */
1036 @Macro Void write1(Event evt, IArg a1);
1037
1038 /*!
1039 * ======== write2 ========
1040 * Generate a `Log` event with 2 arguments
1041 *
1042 * @see #write8
1043 */
1044 @Macro Void write2(Event evt, IArg a1, IArg a2);
1045
1046 /*!
1047 * ======== write3 ========
1048 * Generate a `Log` event with 3 arguments
1049 *
1050 * @see #write8
1051 */
1052 @Macro Void write3(Event evt, IArg a1, IArg a2, IArg a3);
1053
1054 /*!
1055 * ======== write4 ========
1056 * Generate a `Log` event with 4 arguments
1057 *
1058 * @see #write8
1059 */
1060 @Macro Void write4(Event evt, IArg a1, IArg a2, IArg a3, IArg a4);
1061
1062 /*!
1063 * ======== write5 ========
1064 * Generate a `Log` event with 5 arguments
1065 *
1066 * @see #write8
1067 */
1068 @Macro Void write5(Event evt, IArg a1, IArg a2, IArg a3, IArg a4, IArg a5);
1069
1070 /*!
1071 * ======== write6 ========
1072 * Generate a `Log` event with 6 arguments
1073 *
1074 * @see #write8
1075 */
1076 @Macro Void write6(Event evt, IArg a1, IArg a2, IArg a3, IArg a4,
1077 IArg a5, IArg a6);
1078
1079 /*!
1080 * ======== write7 ========
1081 * Generate a `Log` event with 7 arguments
1082 *
1083 * @see #write8
1084 */
1085 @Macro Void write7(Event evt, IArg a1, IArg a2, IArg a3, IArg a4,
1086 IArg a5, IArg a6, IArg a7);
1087
1088 /*!
1089 * ======== write8 ========
1090 * Generate a `Log` event with 8 arguments
1091 *
1092 * If the mask in the specified `Log` event has any bit set which is
1093 * also set in the current module's diagnostics mask, then this call to
1094 * write will "raise" the given `Log` event.
1095 *
1096 * @param(evt) the `Log` event to write
1097 * @param(a1) value for first format conversion character
1098 * @param(a2) value for second format conversion character
1099 * @param(a3) value for third format conversion character
1100 * @param(a4) value for fourth format conversion character
1101 * @param(a5) value for fifth format conversion character
1102 * @param(a6) value for sixth format conversion character
1103 * @param(a7) value for seventh format conversion character
1104 * @param(a8) value for eighth format conversion character
1105 */
1106 @Macro Void write8(Event evt, IArg a1, IArg a2, IArg a3, IArg a4,
1107 IArg a5, IArg a6, IArg a7, IArg a8);
1108
1109 /*!
1110 * ======== doPrint ========
1111 * Render an event as text via `{@link System#printf System_printf}`
1112 *
1113 * This method is not gated and may make more than one call to
1114 * `System_printf`. This utility method is typically used within the
1115 * implementation of a logger which initializes
1116 * `{@link #EventRec Log_EventRec}` structures based on `Log` events
1117 * produced by the application.
1118 *
1119 * @param(evRec) a non`NULL` pointer to an initialized `Log_EventRec`
1120 * structure to be formated via
1121 * `{@link System#printf System_printf}`.
1122 */
1123 Void doPrint(EventRec *evRec);
1124
1125 /*!
1126 * @_nodoc
1127 * ======== lookupEventMessage ========
1128 * Returns the format string for the event with the given id.
1129 */
1130 function lookupEventMessage(eventId);
1131
1132 /*!
1133 * @_nodoc
1134 * ======== getTargetArgSize ========
1135 * Returns the target size of a record argument in bytes (not MAUs).
1136 */
1137 function getTargetArgSize();
1138
1139 /*!
1140 * @_nodoc
1141 * ======== lookupEventName ========
1142 */
1143 function lookupEventName(eventId);
1144
1145 /*!
1146 * @_nodoc
1147 * ======== lookupModuleName ========
1148 */
1149 function lookupModuleName(modId);
1150
1151 /*!
1152 * @_nodoc
1153 * ======== getTargetEventRecSize ========
1154 * Returns the record size in bytes (not MAUs).
1155 */
1156 function getTargetEventRecSize();
1157
1158 internal:
1159
1160 1161 1162 1163
1164 metaonly config String idToInfo[string] = [];
1165 }
1166 1167 1168
1169