<commit_before>/**
 * @file logger.h
 * @brief Log over usart functionality
 *
 * \copyright Copyright 2013 /Dev. All rights reserved.
 * \license This project is released under MIT license.
 *
 * @author <NAME> <<EMAIL>>
 * @since 0.1.0
 */

#ifndef UTILS_LOGGER_H
#define UTILS_LOGGER_H

#include "../config.h"

// Do we want logging?
#if defined(UTILS_LOGGER_INFO) || defined(UTILS_LOGGER_DEBUG)

// Make sure USART is enabled
#ifndef COM_USART
#warning Using UTILS_DEBUG while COM_USART not enabled, forcing COM_USART
#define COM_USART
#endif // COM_USART

#include <inttypes.h>
#include <util/delay.h>
#include "../com/usart.h"

extern void logger_init(void);
extern void logger_string(char *string);
extern void logger_string_p(const char *pstring);
extern void logger__number(uint16_t value);
extern void logger_number_as_hex(uint16_t value);
extern void logger_array(uint8_t *data, uint16_t length, char glue);

#if defined(UTILS_LOGGER_DEBUG)

// Info level enabled
#define info_string(s) logger_string(s)
#define info_string_p(s) logger_string_p(s)
#define info_number(x) logger_number(x)
#define info_number_as_hex(x) logger_number_as_hex(x)
#define info_array(x, l) logger_array(x, l)
// Debug level disabled
#define debug_string(...) do {} while (0)
#define debug_string_p(...) do {} while (0)
#define debug_number(...) do {} while (0)
#define debug_number_as_hex(...) do {} while (0)
#define debug_array(...) do {} while (0)

#elif defined(UTILS_LOGGER_INFO)

// Info level enabled
#define info_string(s) logger_string(s)
#define info_string_p(s) logger_string_p(s)
#define info_number(x) logger_number(x)
#define info_number_as_hex(x) logger_number_as_hex(x)
#define info_array(x, l) logger_array(x, l)
// Debug level disabled
#define debug_string(...) do {} while (0)
#define debug_string_p(...) do {} while (0)
#define debug_number(...) do {} while (0)
#define debug_number_as_hex(...) do {} while (0)
#define debug_array(...) do {} while (0)

#endif // UTILS_LOGGER_INFO


#else // UTILS_LOGGER_INFO || UTILS_LOGGER_DEBUG

// No logger wanted, create placeholders
#define logging_init(...) do {} while (0)
// Info level disabled
#define info_string(...) do {} while (0)<commit_msg>Fix debug_* defines<commit_after>/**
 * @file logger.h
 * @brief Log over usart functionality
 *
 * \copyright Copyright 2013 /Dev. All rights reserved.
 * \license This project is released under MIT license.
 *
 * @author <NAME> <<EMAIL>>
 * @since 0.1.0
 */

#ifndef UTILS_LOGGER_H
#define UTILS_LOGGER_H

#include "../config.h"

// Do we want logging?
#if defined(UTILS_LOGGER_INFO) || defined(UTILS_LOGGER_DEBUG)

// Make sure USART is enabled
#ifndef COM_USART
#warning Using UTILS_DEBUG while COM_USART not enabled, forcing COM_USART
#define COM_USART
#endif // COM_USART

#include <inttypes.h>
#include <util/delay.h>
#include "../com/usart.h"

extern void logger_init(void);
extern void logger_string(char *string);
extern void logger_string_p(const char *pstring);
extern void logger__number(uint16_t value);
extern void logger_number_as_hex(uint16_t value);
extern void logger_array(uint8_t *data, uint16_t length, char glue);

#if defined(UTILS_LOGGER_DEBUG)

// Info level enabled
#define info_string(s) logger_string(s)
#define info_string_p(s) logger_string_p(s)
#define info_number(x) logger_number(x)
#define info_number_as_hex(x) logger_number_as_hex(x)
#define info_array(x, l) logger_array(x, l)
// Debug level disabled
#define debug_string(s) logger_string(s)
#define debug_string_p(s) logger_string_p(s)
#define debug_number(x) logger_number(x)
#define debug_number_as_hex(x) logger_number_as_hex(x)
#define debug_array(x, l) logger_array(x, l)

#elif defined(UTILS_LOGGER_INFO)

// Info level enabled
#define info_string(s) logger_string(s)
#define info_string_p(s) logger_string_p(s)
#define info_number(x) logger_number(x)
#define info_number_as_hex(x) logger_number_as_hex(x)
#define info_array(x, l) logger_array(x, l)
// Debug level disabled
#define debug_string(...) do {} while (0)
#define debug_string_p(...) do {} while (0)
#define debug_number(...) do {} while (0)
#define debug_number_as_hex(...) do {} while (0)
#define debug_array(...) do {} while (0)

#endif // UTILS_LOGGER_INFO


#else // UTILS_LOGGER_INFO || UTILS_LOGGER_DEBUG

// No logger wanted, create placeholders
#define logging_init(...) do {} while (0)
// Info level disabled
#define info_string(...) do {} while (0)
{'fraction_non_alphanumeric': 0.13278948561069567, 'fraction_numerical': 0.010650351234987537, 'mean_word_length': 5.443795620437956, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2597110', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1593, 'n_words': 429}