<commit_before>/**
 * @file       BlynkDebug.h
 * @author     <NAME>
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 <NAME>
 * @date       Jan 2015
 * @brief      Debug utilities
 *
 */

#ifndef BlynkDebug_h
#define BlynkDebug_h

#include "BlynkConfig.h"
#include <stddef.h>

// General defines

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#define BLYNK_ATTR_PACKED __attribute__ ((__packed__))
#define BLYNK_FORCE_INLINE __attribute__((always_inline))
#define BLYNK_NORETURN __attribute__ ((noreturn))

#if defined(__AVR__)
    #include <avr/pgmspace.h>
    #define BLYNK_HAS_PROGMEM
    #define BLYNK_PROGMEM PROGMEM
    #define _S(s) PSTR(s)
#else
    #define BLYNK_PROGMEM
    #define _S(s) s
#endif

// Diagnostic defines

size_t BlynkFreeRam();
void BlynkReset();
void BlynkFatal() BLYNK_NORETURN;

#define BLYNK_FATAL(msg, ...){ BLYNK_LOG(msg, ##__VA_ARGS__); BlynkFatal(); }
#define BLYNK_LOG_RAM()      { BLYNK_LOG("Free RAM: %d", BlynkFreeRam()); }
#define BLYNK_LOG_FN()       BLYNK_LOG("%s@%d", __FUNCTION__, __LINE__);

#ifdef BLYNK_PRINT

    #if defined(ARDUINO)
        #include <stdio.h>
        #include <stdarg.h>
        #include <Arduino.h>

        #define BLYNK_DBG_DUMP(msg, addr, len) { BLYNK_PRINT.print(msg); BLYNK_PRINT.write((uint8_t*)addr, len); BLYNK_PRINT.println(); }
        #define BLYNK_DBG_BREAK()    { for(;;); }
#if defined(__SAM3X8E__)
        #define BLYNK_LOG(msg, ...)  blynk_dbg_print(msg, ##__VA_ARGS__)
#else
        #define BLYNK_LOG(msg, ...)  blynk_dbg_print(_S(msg), ##__VA_ARGS__)
#endif
        #define BLYNK_ASSERT(expr)   { if(!(expr)) { BLYNK_LOG("Assertion %s failed.", #expr); BLYNK_DBG_BREAK() } }

        static
        void blynk_dbg_print(const BLYNK_PROGMEM char *fmt, ...)
        {
            va_list ap;
            va_start(ap, fmt);
            char buff[128];
            BLYNK_PRINT.print('[');
            BLYNK_PRINT.print(millis());
            BLYNK_PRINT.print(F("] "));
#if defined(__AVR__)
            vsnprintf_P(buff, sizeof(buff), fmt, ap);
#else
            vsnprintf(buff, sizeof(buff), fmt, ap);
#endif<commit_msg>Update BlynkDebug.h<commit_after>/**
 * @file       BlynkDebug.h
 * @author     <NAME>
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 <NAME>
 * @date       Jan 2015
 * @brief      Debug utilities
 *
 */

#ifndef BlynkDebug_h
#define BlynkDebug_h

#include "BlynkConfig.h"
#include <stddef.h>

// General defines

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#define BLYNK_ATTR_PACKED __attribute__ ((__packed__))
#define BLYNK_FORCE_INLINE __attribute__((always_inline))
#define BLYNK_NORETURN __attribute__ ((noreturn))

#if defined(__AVR__)
    #include <avr/pgmspace.h>
    #define BLYNK_HAS_PROGMEM
    #define BLYNK_PROGMEM PROGMEM
    #define _S(s) PSTR(s)
#else
    #define BLYNK_PROGMEM
    #define _S(s) s
#endif

// Diagnostic defines

size_t BlynkFreeRam();
void BlynkReset();
void BlynkFatal() BLYNK_NORETURN;

#define BLYNK_FATAL(msg, ...){ BLYNK_LOG(msg, ##__VA_ARGS__); BlynkFatal(); }
#define BLYNK_LOG_RAM()      { BLYNK_LOG("Free RAM: %d", BlynkFreeRam()); }
#define BLYNK_LOG_FN()       BLYNK_LOG("%s@%d", __FUNCTION__, __LINE__);

#ifdef BLYNK_PRINT

    #if defined(ARDUINO) || defined(SPARK)
        #include <stdio.h>
        #include <stdarg.h>
#if defined(ARDUINO)
        #include <Arduino.h>
#endif

        #define BLYNK_DBG_DUMP(msg, addr, len) { BLYNK_PRINT.print(msg); BLYNK_PRINT.write((uint8_t*)addr, len); BLYNK_PRINT.println(); }
        #define BLYNK_DBG_BREAK()    { for(;;); }
#if defined(__SAM3X8E__)
        #define BLYNK_LOG(msg, ...)  blynk_dbg_print(msg, ##__VA_ARGS__)
#else
        #define BLYNK_LOG(msg, ...)  blynk_dbg_print(_S(msg), ##__VA_ARGS__)
#endif
        #define BLYNK_ASSERT(expr)   { if(!(expr)) { BLYNK_LOG("Assertion %s failed.", #expr); BLYNK_DBG_BREAK() } }

        static
        void blynk_dbg_print(const BLYNK_PROGMEM char *fmt, ...)
        {
            va_list ap;
            va_start(ap, fmt);
            char buff[128];
            BLYNK_PRINT.print('[');
            BLYNK_PRINT.print(millis());
            BLYNK_PRINT.print(F("] "));
#if defined(__AVR__)
            vsnprintf_P(buff, sizeof(buff), fmt, ap);
#else
            vsnprintf(buff, sizeof(buff), fmt, ap);
#endif
{'fraction_non_alphanumeric': 0.14978070175438596, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 3.4541015625, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6234888', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1742, 'n_words': 344}