VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae_logger.hpp File Reference
#include "../../include/vae/vae.hpp"
#include <stdio.h>
#include "../wrapped/vae_profiler.hpp"
#include <stdarg.h>
#include <cstring>
#include "../../external/headeronly/stb_sprintf.h"
Include dependency graph for vae_logger.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define STB_SPRINTF_IMPLEMENTATION
 
#define VAE_ERROR(msg, ...)   vae_print_path(vae::LogLevel::Error, __FILE__, __LINE__, msg, ## __VA_ARGS__);
 
#define VAE_DEBUG(msg, ...)   vae_print_path(vae::LogLevel::Debug, __FILE__, __LINE__, msg, ## __VA_ARGS__);
 
#define VAE_INFO(msg, ...)   vae_print_path(vae::LogLevel::Info, __FILE__, __LINE__, msg, ## __VA_ARGS__);
 
#define VAE_WARN(msg, ...)   vae_print_path(vae::LogLevel::Warn, __FILE__, __LINE__, msg, ## __VA_ARGS__);
 
#define VAE_DEBUG_VOICES(msg, ...)
 
#define VAE_DEBUG_EVENT(msg, ...)
 

Functions

void vae_print (vae::LogLevel level, const char *message)
 
void vae_print_va (vae::LogLevel level, const char *format, va_list va)
 
void vae_print_path (vae::LogLevel level, const char *path, int line, const char *format,...)
 

Macro Definition Documentation

◆ STB_SPRINTF_IMPLEMENTATION

#define STB_SPRINTF_IMPLEMENTATION

Definition at line 28 of file vae_logger.hpp.

◆ VAE_DEBUG

#define VAE_DEBUG (   msg,
  ... 
)    vae_print_path(vae::LogLevel::Debug, __FILE__, __LINE__, msg, ## __VA_ARGS__);

Definition at line 83 of file vae_logger.hpp.

◆ VAE_DEBUG_EVENT

#define VAE_DEBUG_EVENT (   msg,
  ... 
)

Definition at line 96 of file vae_logger.hpp.

◆ VAE_DEBUG_VOICES

#define VAE_DEBUG_VOICES (   msg,
  ... 
)

Definition at line 90 of file vae_logger.hpp.

◆ VAE_ERROR

#define VAE_ERROR (   msg,
  ... 
)    vae_print_path(vae::LogLevel::Error, __FILE__, __LINE__, msg, ## __VA_ARGS__);

Definition at line 80 of file vae_logger.hpp.

◆ VAE_INFO

#define VAE_INFO (   msg,
  ... 
)    vae_print_path(vae::LogLevel::Info, __FILE__, __LINE__, msg, ## __VA_ARGS__);

Definition at line 84 of file vae_logger.hpp.

◆ VAE_WARN

#define VAE_WARN (   msg,
  ... 
)    vae_print_path(vae::LogLevel::Warn, __FILE__, __LINE__, msg, ## __VA_ARGS__);

Definition at line 85 of file vae_logger.hpp.

Function Documentation

◆ vae_print()

void vae_print ( vae::LogLevel  level,
const char *  message 
)

Definition at line 18 of file vae_logger.hpp.

18 {
19 printf(message);
20 printf("\n");
21 }
Here is the caller graph for this function:

◆ vae_print_path()

void vae_print_path ( vae::LogLevel  level,
const char *  path,
int  line,
const char *  format,
  ... 
)

Definition at line 44 of file vae_logger.hpp.

44 {
45 if (path == nullptr) { return; }
46 if (format == nullptr) { return; }
47
48 constexpr int bufferSize = 1024;
49 constexpr int fixedPathLength = 16;
50 static bool locked = false;
51 static char buffer[bufferSize];
52
53 // Make all paths the same length so log is less messy
54 int pathLength = strlen(path);
55 if (fixedPathLength < pathLength) {
56 path += (pathLength - fixedPathLength);
57 }
58
59 while(locked) { }
60 locked = true;
61
62 switch (level) {
63 case vae::LogLevel::Debug: stbsp_snprintf(buffer, bufferSize, "DEBUG | %s:%i \t| %s", path, line, format); break;
64 case vae::LogLevel::Info: stbsp_snprintf(buffer, bufferSize, " INFO | %s:%i \t| %s", path, line, format); break;
65 case vae::LogLevel::Warn: stbsp_snprintf(buffer, bufferSize, " WARN | %s:%i \t| %s", path, line, format); break;
66 case vae::LogLevel::Error: stbsp_snprintf(buffer, bufferSize, "ERROR | %s:%i \t| %s", path, line, format); break;
67 case vae::LogLevel::Ciritical: stbsp_snprintf(buffer, bufferSize, " CRIT | %s:%i \t| %s", path, line, format); break;
68 default: break;
69 }
70
71 va_list va;
72 va_start(va, format);
73 vae_print_va(level, buffer, va);
74 va_end(va);
75
76 locked = false;
77 }
void vae_print_va(vae::LogLevel level, const char *format, va_list va)
Definition: vae_logger.hpp:31
Here is the call graph for this function:

◆ vae_print_va()

void vae_print_va ( vae::LogLevel  level,
const char *  format,
va_list  va 
)

Definition at line 31 of file vae_logger.hpp.

31 {
32 constexpr int bufferSize = 1024;
33 static bool locked = false;
34 static char buffer[bufferSize];
35 while(locked) { }
36 locked = true;
37 const int length = stbsp_vsnprintf(buffer, bufferSize, format, va);
38 buffer[bufferSize - 1] = '\0';
39 vae_print(level, buffer);
40 VAE_PROFILER_MESSAGE(buffer, length)
41 locked = false;
42 }
void vae_print(vae::LogLevel level, const char *message)
Definition: vae_logger.hpp:18
#define VAE_PROFILER_MESSAGE(msg, size)
Send dynamic string message.
Here is the call graph for this function:
Here is the caller graph for this function: