Write error messages to STDERR for diagnostic purposes. This module is not thread safe.
LogWriter | Write error messages to STDERR for diagnostic purposes. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file of LogWriter. |
C-kern/ | Implementation file LogWriter impl. |
Types | |
struct logwriter_t | Exports logwriter_t. |
struct logwriter_chan_t | Exports logwriter_chan_t. |
Functions | |
test | |
unittest_io_writer_log_logwriter | Tests <initthread_logwriter> and functionality of logwriter_t. |
logwriter_t | A logwriter writes the console channel messages to STDOUT any other channels to STDERR. |
addr | Address of allocated buffer. |
size | Size in bytes of allocated buffer. |
chan | Array of logwriter_chan_t. |
initthread | |
interface_logwriter | This function is called from <init_threadcontext>. |
lifetime | |
logwriter_FREE | Static initializer. |
init_logwriter | Allocates memory for the structure and initializes all variables to default values. |
free_logwriter | Frees resources and frees memory of log object. |
query | |
getbuffer_logwriter | Returns content of internal buffer corrseponding to channel as C-string. |
getstate_logwriter | Returns current log_state_e of channel (log_channel_e). |
compare_logwriter | Returns 0 if logbuffer compares equal to channel content of lgwrt. |
config | |
setstate_logwriter | Change log_state_e of log_channel_e channel to logstate. |
change | |
clearbuffer_logwriter | Clears log buffer (sets length of logbuffer to 0). |
flushbuffer_logwriter | Writes content of buffer to STDERR or configured file descriptor and clears log buffer. |
printf_logwriter | Writes new log entry to internal buffer. |
printtext_logwriter | Writes a text resource to internal buffer. |
vprintf_logwriter | Same as printf_logwriter except that variadic arguments are replaced by args. |
inline implementation |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2011 Jörg Seebohn
Header file of LogWriter.
Implementation file LogWriter impl.
typedef struct logwriter_t logwriter_t
Exports logwriter_t.
typedef struct logwriter_chan_t logwriter_chan_t
Exports logwriter_chan_t.
test | |
unittest_io_writer_log_logwriter | Tests <initthread_logwriter> and functionality of logwriter_t. |
int unittest_io_writer_log_logwriter( void )
Tests <initthread_logwriter> and functionality of logwriter_t.
struct logwriter_t
A logwriter writes the console channel messages to STDOUT any other channels to STDERR. Before anything is written out the messages are stored in an internal buffer. If less then log_config_MINSIZE plus “terminating \0 byte” bytes are free the buffer is written out (flushed) before any new mesage is appended. If messages should be appended the buffer is not written out until the last message was appended. In this case messages are truncated if they are bigger than log_config_MINSIZE.
In case of KONFIG_SUBSYS_THREAD is not defined static logmain_t is used instead of logwriter_t.
addr | Address of allocated buffer. |
size | Size in bytes of allocated buffer. |
chan | Array of logwriter_chan_t. |
initthread | |
interface_logwriter | This function is called from <init_threadcontext>. |
lifetime | |
logwriter_FREE | Static initializer. |
init_logwriter | Allocates memory for the structure and initializes all variables to default values. |
free_logwriter | Frees resources and frees memory of log object. |
query | |
getbuffer_logwriter | Returns content of internal buffer corrseponding to channel as C-string. |
getstate_logwriter | Returns current log_state_e of channel (log_channel_e). |
compare_logwriter | Returns 0 if logbuffer compares equal to channel content of lgwrt. |
config | |
setstate_logwriter | Change log_state_e of log_channel_e channel to logstate. |
change | |
clearbuffer_logwriter | Clears log buffer (sets length of logbuffer to 0). |
flushbuffer_logwriter | Writes content of buffer to STDERR or configured file descriptor and clears log buffer. |
printf_logwriter | Writes new log entry to internal buffer. |
printtext_logwriter | Writes a text resource to internal buffer. |
vprintf_logwriter | Same as printf_logwriter except that variadic arguments are replaced by args. |
logwriter_chan_t *chan
Array of logwriter_chan_t. A log_channel_e is mapped to a logwriter_chan_t with help of this array.
struct log_it * interface_logwriter( void )
This function is called from <init_threadcontext>. Used to initialize interface of log_t.
void getbuffer_logwriter( const logwriter_t * lgwrt, uint8_t channel, /*out*/uint8_t ** buffer, /*out*/size_t * size )
Returns content of internal buffer corrseponding to channel as C-string. The string has a trailing NULL byte, i.e. buffer[size] == 0. The address of the buffer is valid as long as no call to free_logwriter is made. The content changes if the buffer is flushed or cleared and new log entries are written. Do not free the returned buffer. It points to an internal buffer used by the implementation.
uint8_t getstate_logwriter( const logwriter_t * lgwrt, uint8_t channel )
Returns current log_state_e of channel (log_channel_e).
void setstate_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t logstate )
Change log_state_e of log_channel_e channel to logstate.
void printf_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t flags, const struct log_header_t * header, const char * format, ... ) __attribute__ ((__format__ (__printf__, 5, 6)))
Writes new log entry to internal buffer. If the entry is bigger than log_config_MINSIZE it may be truncated if internal buffer size is lower.
void printtext_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t flags, const struct log_header_t * header, log_text_f textf, ... )
Writes a text resource to internal buffer. If the entry is bigger than log_config_MINSIZE it may be truncated if internal buffer size is lower.
void vprintf_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t flags, const struct log_header_t * header, const char * format, va_list args )
Same as printf_logwriter except that variadic arguments are replaced by args. Function used internally to implement printf_logwriter.
Exports logwriter_t.
typedef struct logwriter_t logwriter_t
A logwriter writes the console channel messages to STDOUT any other channels to STDERR.
struct logwriter_t
Exports logwriter_chan_t.
typedef struct logwriter_chan_t logwriter_chan_t
Extends logbuffer_t with isappend mode and log_state_e.
struct logwriter_chan_t
Tests initthread_logwriter and functionality of logwriter_t.
int unittest_io_writer_log_logwriter( void )
Address of allocated buffer.
uint8_t *addr
Size in bytes of allocated buffer.
size_t size
Array of logwriter_chan_t.
logwriter_chan_t *chan
This function is called from init_threadcontext.
struct log_it * interface_logwriter( void )
Static initializer.
#define logwriter_FREE { 0, 0, 0 }
Allocates memory for the structure and initializes all variables to default values.
int init_logwriter( /*out*/logwriter_t * lgwrt )
Frees resources and frees memory of log object.
int free_logwriter( logwriter_t * lgwrt )
Returns content of internal buffer corrseponding to channel as C-string.
void getbuffer_logwriter( const logwriter_t * lgwrt, uint8_t channel, /*out*/uint8_t ** buffer, /*out*/size_t * size )
Returns current log_state_e of channel (log_channel_e).
uint8_t getstate_logwriter( const logwriter_t * lgwrt, uint8_t channel )
Returns 0 if logbuffer compares equal to channel content of lgwrt.
int compare_logwriter( const logwriter_t * lgwrt, uint8_t channel, size_t logsize, const uint8_t logbuffer[logsize] )
Change log_state_e of log_channel_e channel to logstate.
void setstate_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t logstate )
Clears log buffer (sets length of logbuffer to 0).
void clearbuffer_logwriter( logwriter_t * lgwrt, uint8_t channel )
Writes content of buffer to STDERR or configured file descriptor and clears log buffer.
void flushbuffer_logwriter( logwriter_t * lgwrt, uint8_t channel )
Writes new log entry to internal buffer.
void printf_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t flags, const struct log_header_t * header, const char * format, ... ) __attribute__ ((__format__ (__printf__, 5, 6)))
Writes a text resource to internal buffer.
void printtext_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t flags, const struct log_header_t * header, log_text_f textf, ... )
Same as printf_logwriter except that variadic arguments are replaced by args.
void vprintf_logwriter( logwriter_t * lgwrt, uint8_t channel, uint8_t flags, const struct log_header_t * header, const char * format, va_list args )
No object necessary.
struct logmain_t
Uses iobj_DECLARE to declare object supporting interface log_it.
iobj_DECLARE( log_t, log )