AVRly - AVR Development Resources
log_system.h File Reference

Driver file providing logging functionality over USART, to print debug messages and values to a teminal program on your PC. More...

Go to the source code of this file.

Enumerations

enum  eLogLevel {
  NONE , INFO , DEBUG , VERBOSE_DEBUG ,
  WARNING , ERROR , NONE , INFO ,
  DEBUG , VERBOSE_DEBUG , WARNING , ERROR
}
 

Functions

void init_log_system (void)
 Initialisation routine - call this function once at startup before using other functions. More...
 
void log_message (const char *p_tag, enum eLogLevel level, const char *msg)
 
void log_message_with_dec_val (const char *p_tag, enum eLogLevel level, const char *msg, uint8_t val)
 
void log_message_with_16bit_dec_val (const char *p_tag, enum eLogLevel level, const char *msg, uint16_t val)
 
void log_message_with_bin_val (const char *p_tag, enum eLogLevel level, const char *msg, uint8_t val)
 
void log_message_with_hex_val (const char *p_tag, enum eLogLevel level, const char *msg, uint8_t val)
 
void log_set_output_level (const char *p_tag, enum eLogLevel level)
 
void log_global_on (void)
 Turns logging system on globally. More...
 
void log_global_off (void)
 Turns logging system off globally. More...
 

Detailed Description

Driver file providing logging functionality over USART, to print debug messages and values to a teminal program on your PC.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Jason Duffy
Date
15th March 2022
See also

Definition in file log_system.h.

Enumeration Type Documentation

◆ eLogLevel

enum eLogLevel

Definition at line 37 of file log_system.h.

37{NONE, INFO, DEBUG, VERBOSE_DEBUG, WARNING, ERROR};

Function Documentation

◆ init_log_system()

void init_log_system ( void  )

Initialisation routine - call this function once at startup before using other functions.

Log system will then be turned on by default - call log_global_off() if you do not wish it to be.

Definition at line 46 of file log_system.c.

47{
48 init_usart();
50 log_message(p_system_tag, INFO, "Log system initialised");
51};
void init_usart(void)
Takes the defined BAUD and F_CPU, calculates the bit-clock multiplier, configures the hardware USART ...
Definition: usart.c:50
void log_global_on(void)
Turns logging system on globally.
Definition: log_system.c:133
void log_message(log_system_config_t *p_config, log_type_t level, const char *msg)
Sends only the system tag, log level and message string.
Definition: log_system.c:93

◆ log_message()

void log_message ( const char *  p_tag,
enum eLogLevel  level,
const char *  msg 
)

Definition at line 54 of file log_system.c.

55{
56 print_tag_and_log_level(p_tag, level);
57 print_string(msg);
58}
void print_string(const char myString[])
Utility function to transmit an entire string from RAM.
Definition: usart.c:67
void print_tag_and_log_level(const char *p_tag, log_type_t level)
Utility function to print labels over serial.
Definition: log_system.c:260

◆ log_message_with_dec_val()

void log_message_with_dec_val ( const char *  p_tag,
enum eLogLevel  level,
const char *  msg,
uint8_t  val 
)

Definition at line 61 of file log_system.c.

65{
66 print_tag_and_log_level(p_tag, level);
67 print_string(msg);
68 print_string(" ");
69 print_byte(val);
70}
void print_byte(uint8_t byte)
Prints a byte out as its 3-digit ascii equivalent.
Definition: usart.c:106

◆ log_message_with_16bit_dec_val()

void log_message_with_16bit_dec_val ( const char *  p_tag,
enum eLogLevel  level,
const char *  msg,
uint16_t  val 
)

Definition at line 74 of file log_system.c.

78{
79 print_tag_and_log_level(p_tag, level);
80 print_string(msg);
81 print_string(" ");
82 print_word(val);
83}
void print_word(uint16_t word)
Prints a word (16-bits) out as its 5-digit ascii equivalent.
Definition: usart.c:115

◆ log_message_with_bin_val()

void log_message_with_bin_val ( const char *  p_tag,
enum eLogLevel  level,
const char *  msg,
uint8_t  val 
)

Definition at line 87 of file log_system.c.

91{
92 print_tag_and_log_level(p_tag, level);
93 print_string(msg);
94 print_string(" ");
96}
void print_binary_byte(uint8_t byte)
Prints a byte out in 1s and 0s.
Definition: usart.c:125

◆ log_message_with_hex_val()

void log_message_with_hex_val ( const char *  p_tag,
enum eLogLevel  level,
const char *  msg,
uint8_t  val 
)

Definition at line 115 of file log_system.c.

119{
120 print_tag_and_log_level(p_tag, level);
121 print_string(msg);
122 print_string(" ");
123 print_hex_byte(val);
124}
void print_hex_byte(uint8_t byte)
Prints a byte out in hexadecimal.
Definition: usart.c:155

◆ log_set_output_level()

void log_set_output_level ( const char *  p_tag,
enum eLogLevel  level 
)

Definition at line 127 of file log_system.c.

128{
129
130}

◆ log_global_on()

void log_global_on ( void  )

Turns logging system on globally.

Definition at line 133 of file log_system.c.

134{
135 log_system_enabled = true;
136}

◆ log_global_off()

void log_global_off ( void  )

Turns logging system off globally.

Definition at line 139 of file log_system.c.

140{
141 log_system_enabled = false;
142}