summaryrefslogtreecommitdiff
path: root/src/logger.h
blob: dbc059f4e1ae3b16b3ae8da2130e74e47fad60a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef LOGGER_H_
#define LOGGER_H_

#include <stdbool.h>

#ifdef DEBUG
#define DEBUG_PRINT(fmt, args...)                                              \
  fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, __FILE__, __LINE__, __func__,     \
          ##args)
#else
#define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */
#endif

#define LOG(component, fmt, args...) append_log("[%s] " fmt, component, ##args)

struct logger {
  struct nk_text_edit *text_edit;
  unsigned long box_lines;
  struct nk_scroll *scrollbar;
  bool extend_box;
  int font_height;
};

struct logger *setup_logger(void);

void append_log(const char *fmt, ...);

void clear_log();

#endif