|
Open Model Railroad Network (OpenMRN)
|
Go to the source code of this file.
Macros | |
| #define | __STDC_VERSION__ 199901L |
| Hack to make vsnprintf show up. | |
| #define | LOCK_LOG |
| Called before starting to use the logging buffer. | |
| #define | UNLOCK_LOG |
| Called after the log buffer is flushed. | |
| #define | GLOBAL_LOG_OUTPUT log_output |
| Used for writing log buffersto the log output. | |
| #define | LOG_MAYBE_DIE(level) 0 |
| Splits the death behavior of FreeRTOS (where we just blink) from everything else (where we actually print a death message). | |
| #define | LOG(level, message...) |
| Conditionally write a message to the logging output. | |
| #define | LOG_ERROR(message...) LOG(LEVEL_ERROR, message) |
| Shorthand for LOG(LEVEL_ERROR, message...). See LOG. | |
| #define | LOGLEVEL INFO |
| Default loglevel. | |
| #define | ERRNOCHECK(where, x...) |
| Calls the function x, and if the return value is negative, prints errno as error message to stderr and exits the current program. | |
Functions | |
| void | log_output (char *buf, int size) |
| Prints a line of log to the log output destination. | |
| void | print_errno_and_exit (const char *where) |
| Prints an error message about errno to std error and terminates the current program. | |
Variables | |
| static const int | ALWAYS = -1 |
| Loglevel that is always printed. | |
| static const int | FATAL = 0 |
| Loglevel that kills the current process. | |
| static const int | LEVEL_ERROR = 1 |
| Loglevel that is always printed, reporting an error. | |
| static const int | WARNING = 2 |
| Loglevel that is always printed, reporting a warning or a retryable error. | |
| static const int | INFO = 3 |
| Loglevel that is printed by default, reporting some status information. | |
| static const int | VERBOSE = 4 |
| Loglevel that is usually not printed, reporting debugging information. | |
| char | logbuffer [256] |
| Temporary buffer to sprintf() the log lines into. | |
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.
Facility to do debug printf's on a configurable loglevel.
Definition in file logging.h.
| #define __STDC_VERSION__ 199901L |
| #define ERRNOCHECK | ( | where, | |
| x... | |||
| ) |
Calls the function x, and if the return value is negative, prints errno as error message to stderr and exits the current program.
| where | is a string, describing the operation that's being executed. |
| x | is an expression, usually a system function call with arguments that needsto be run and the return value checked. |
example usage: ERRNOCHECK("file close", close(fd_));
| #define GLOBAL_LOG_OUTPUT log_output |
| #define LOCK_LOG |
| #define LOG | ( | level, | |
| message... | |||
| ) |
Conditionally write a message to the logging output.
| level | is the log level; if the configured loglevel is smaller, then the log is not printed, not rendered, and the rendering code is never even compiled. This makes it cheap to have LOG(VERBOSE, ...) messages left in the code everywhere. |
| message | is a printf format argument and possibly more arguments that are referenced from the printf format. |
| #define LOG_ERROR | ( | message... | ) | LOG(LEVEL_ERROR, message) |
Shorthand for LOG(LEVEL_ERROR, message...). See LOG.
| #define LOG_MAYBE_DIE | ( | level | ) | 0 |
| void log_output | ( | char * | buf, |
| int | size | ||
| ) |
Prints a line of log to the log output destination.
| buf | is the logging buffer. Guaranteed to be available until this function returns. |
| size | is now many bytes are there in the logging buffer. There is never a terminating in the log buffer. There is a terminating zero at buf[size]. |
Prints a line of log to the log output destination.
This is a definition fo a C++ symbol, and should be included exactly once into one .cxx file; typicall into main.cxx.
| buf | pointer to bytes to log. Does not contain a . |
| size | how may bytes to log. |
Definition at line 73 of file logging.cxx.
| void print_errno_and_exit | ( | const char * | where | ) |
Prints an error message about errno to std error and terminates the current program.
| where | C-style string describing where the error has happened. Will be printed too. |
Definition at line 47 of file errno_exit.c.
|
static |
|
static |
|
static |
|
static |
|
extern |
Temporary buffer to sprintf() the log lines into.
Definition at line 42 of file logging.cxx.
|
static |