Go to the documentation of this file.
1 /*
2  * SocialLedge.com - Copyright (C) 2013
3  *
4  * This file is part of free software framework for embedded processors.
5  * You can use it and/or distribute it as long as this copyright header
6  * remains unmodified. The code is free for personal use and requires
7  * permission to use in a commercial product.
8  *
9  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
10  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
12  * I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
13  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
14  *
15  * You can reach the author of this software at :
16  * p r e e t . w i k i @ g m a i l . c o m
17  */
18 
29 #ifndef FILE_LOGGER_HPP__
30 #define FILE_LOGGER_HPP__
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 #include <stdint.h>
35 
36 
37 
58 #define FILE_LOGGER_BUFFER_SIZE (1 * 1024)
59 #define FILE_LOGGER_NUM_BUFFERS 10
60 #define FILE_LOGGER_LOG_MSG_MAX_LEN 150
61 #define FILE_LOGGER_FILENAME "0:log.csv"
62 #define FILE_LOGGER_STACK_SIZE (3 * 512 / 4)
63 #define FILE_LOGGER_FLUSH_TIME_SEC (1 * 60)
64 #define FILE_LOGGER_BLOCK_TIME_MS (10)
65 #define FILE_LOGGER_KEEP_FILE_OPEN (0)
66 
74 typedef enum {
80 } logger_msg_t;
81 
86 void logger_init(uint8_t logger_priority);
87 
96 void logger_set_printf(logger_msg_t type, bool enable);
97 
108 #define LOG_ERROR(msg, p...) logger_log (log_error, __FILE__, __FUNCTION__, __LINE__, msg, ## p)
109 #define LOG_WARN(msg, p...) logger_log (log_warn, __FILE__, __FUNCTION__, __LINE__, msg, ## p)
110 #define LOG_INFO(msg, p...) logger_log (log_info, __FILE__, __FUNCTION__, __LINE__, msg, ## p)
111 #define LOG_DEBUG(msg, p...) logger_log (log_debug, __FILE__, __FUNCTION__, __LINE__, msg, ## p)
112 
124 #define LOG_SIMPLE_MSG(msg, p...) logger_log (log_info, NULL, NULL, 0, msg, ## p)
125 
133 #define LOG_RAW_MSG(msg, p...) logger_log_raw(msg, ## p)
134 
142 #define LOG_FLUSH() logger_send_flush_request()
143 
144 
145 
153 void logger_send_flush_request(void);
154 
159 uint32_t logger_get_logged_call_count(logger_msg_t severity);
160 
168 uint16_t logger_get_blocked_call_count(void);
169 
176 
181 uint16_t logger_get_num_buffers_watermark(void);
182 
183 
184 
185 
186 
187 /* Do not use rest of the API after this line */
188 
193 void logger_log(logger_msg_t type, const char * filename, const char * func_name, unsigned line_num,
194  const char * msg, ...);
195 
200 void logger_log_raw(const char * msg, ...);
201 
202 
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 #endif /* FILE_LOGGER_HPP__ */
logger_msg_t
Definition: file_logger.h:74
Definition: file_logger.h:77
void logger_log(logger_msg_t type, const char *filename, const char *func_name, unsigned line_num, const char *msg,...)
Definition: file_logger.c:397
uint16_t logger_get_num_buffers_watermark(void)
Definition: file_logger.c:370
uint16_t logger_get_blocked_call_count(void)
Definition: file_logger.c:360
Marks the last entry, do not use.
Definition: file_logger.h:79
void logger_set_printf(logger_msg_t type, bool enable)
Definition: file_logger.c:386
Definition: file_logger.h:76
void logger_send_flush_request(void)
Definition: file_logger.c:346
void logger_init(uint8_t logger_priority)
Definition: file_logger.c:375
void logger_log_raw(const char *msg,...)
Definition: file_logger.c:476
uint16_t logger_get_highest_file_write_time_ms(void)
Definition: file_logger.c:365
Definition: file_logger.h:78
uint32_t logger_get_logged_call_count(logger_msg_t severity)
Definition: file_logger.c:355
Debug logs are printed to stdio (printf) unless disabled by logger_set_printf()
Definition: file_logger.h:75