reactor-c
C Runtime for Lingua Franca
|
#include <stdarg.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | lf_stat_ll |
Macros | |
#define | ATTRIBUTE_FORMAT_PRINTF(f, s) |
#define | CONCATENATE_THREE_STRINGS(__string1, __string2, __string3) __string1 __string2 __string3 |
#define | LF_LEVEL(index) (index & 0xffffLL) |
#define | LF_MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) |
#define | LF_MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) |
#define | LOG_LEVEL_ERROR 0 |
#define | LOG_LEVEL_WARNING 1 |
#define | LOG_LEVEL_INFO 2 |
#define | LOG_LEVEL_LOG 3 |
#define | LOG_LEVEL_DEBUG 4 |
#define | LOG_LEVEL_ALL 255 |
#define | LOG_LEVEL LOG_LEVEL_INFO |
#define | LF_PRINT_LOG(format, ...) |
#define | LF_PRINT_DEBUG(format, ...) |
Typedefs | |
typedef struct lf_stat_ll | lf_stat_ll |
Variables | |
int | _lf_my_fed_id |
Copyright (c) 2020, The University of California at Berkeley.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Header file for utility types and functions for Lingua Franca programs.
A handy macro that can concatenate three strings. Useful in the LF_PRINT_DEBUG macro and lf_print_error functions that want to concatenate a "DEBUG: " or "ERROR: " to the beginning of the message and a new line format
at the end.
#define LF_LEVEL | ( | index | ) | (index & 0xffffLL) |
Macro for extracting the level from the index of a reaction. A reaction that has no upstream reactions has level 0. Other reactions have a level that is the length of the longest upstream chain to a reaction with level 0 (inclusive). This is used, along with the deadline, to sort reactions in the reaction queue. It ensures that reactions that are upstream in the dependence graph execute before reactions that are downstream.
#define LF_PRINT_DEBUG | ( | format, | |
... | |||
) |
A macro used to print useful debug information. It can be enabled by setting the target property 'logging' to 'DEBUG' or by defining LOG_LEVEL to 2 in the top-level preamble. The input to this macro is exactly like printf: (format, ...). "DEBUG: " is prepended to the beginning of the message and a newline is appended to the end of the message.
#define LF_PRINT_LOG | ( | format, | |
... | |||
) |
A macro used to print useful logging information. It can be enabled by setting the target property 'logging' to 'LOG' or by defining LOG_LEVEL to LOG_LEVEL_LOG or LOG_LEVEL_DEBUG in the top-level preamble. The input to this macro is exactly like printf: (format, ...). "LOG: " is prepended to the beginning of the message and a newline is appended to the end of the message.
#define LOG_LEVEL LOG_LEVEL_INFO |
Default log level.
#define LOG_LEVEL_ALL 255 |
#define LOG_LEVEL_DEBUG 4 |
#define LOG_LEVEL_ERROR 0 |
LOG_LEVEL is set in generated code to 0 through 4 if the target logging property is error, warning, info, log, or debug. The default level is info (2). Currently, 0, 1, and 2 are treated identically and lf_print_error, lf_print_warning, and lf_print all result in printed output. If log is set (3), then LOG_DEBUG messages will be printed as well. If debug is set (4), the LF_PRINT_DEBUG messages will be printed as well.
#define LOG_LEVEL_INFO 2 |
#define LOG_LEVEL_LOG 3 |
#define LOG_LEVEL_WARNING 1 |
Holds generic statistical data
Print the error defined by the errno variable with the specified message as a prefix, then exit with error code 1.
msg | The prefix to the message. |
A shorthand for checking if a condition is true and if not, print an error and exit.
Report an informational message on stdout with a newline appended at the end. If this execution is federated, then the message will be prefaced by "Federate n: ", where n is the federate ID. The arguments are just like printf().
Report an debug message on stdout with the prefix "DEBUG: " and a newline appended at the end. If this execution is federated, then the message will be prefaced by "Federate n: ", where n is the federate ID. The arguments are just like printf().
Report an error with the prefix "ERROR: " and a newline appended at the end. The arguments are just like printf().
Report an error with the prefix "ERROR: " and a newline appended at the end, then exit with the failure code EXIT_FAILURE. The arguments are just like printf().
Report an log message on stdout with the prefix "LOG: " and a newline appended at the end. If this execution is federated, then the message will be prefaced by "Federate n: ", where n is the federate ID. The arguments are just like printf().
Report a warning with the prefix "WARNING: " and a newline appended at the end. The arguments are just like printf().
void lf_register_print_function | ( | print_message_function_t * | function, |
int | log_level | ||
) |
Register a function to display messages. After calling this, all messages passed to the above print functions will be printed using the specified function rather than printf if their log level is greater than the specified level. The level should be one of LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_INFO, LOG_LEVEL_LOG, or LOG_LEVEL_DEBUG.
function | The print message function or NULL to revert to using printf. |
log_level | The level of messages to redirect. |
varargs alternative of "lf_print_debug"
varargs alternative of "lf_print_error"
varargs alternative of "lf_print_error_and_exit"
varargs alternative of "lf_print_log"
varargs alternative of "lf_print_warning"
void void void void void void void typedef void() print_message_function_t | ( | const char * | , |
va_list | |||
) |
Message print function type. The arguments passed to one of these print functions are a printf-style format string followed by a printf-style argument list collected into a va_list (variable argument list).
|
extern |
The ID of this federate. For a non-federated execution, this will be -1. For a federated execution, it will be assigned when the generated function _lf_initialize_trigger_objects() is called.