summaryrefslogtreecommitdiff
path: root/common/console.cpp
blob: 67a6113e310b20a0e830d1f276446febe05a67e4 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// Debug Console
//

#include <stdarg.h>
#include <stdio.h>
#include "console.h"

Console console;

// ============================================================================

Console::Console ()
{
  m_pWindowFunc = NULL;
}

Console::~Console ()
{
}

// ============================================================================

void Console::Print (LC_CONSOLE_LEVEL level, const char* format, ...)
{
  char text[512];
  va_list args;

  va_start (args, format);
  vsprintf (text, format, args);
  va_end (args);

  InternalPrint (level, text);
}

void Console::PrintMisc (const char* format, ...)
{
  char text[512];
  va_list args;

  va_start (args, format);
  vsprintf (text, format, args);
  va_end (args);

  InternalPrint (LC_CONSOLE_MISC, text);
}

void Console::PrintDebug (const char* format, ...)
{
  char text[512];
  va_list args;

  va_start (args, format);
  vsprintf (text, format, args);
  va_end (args);

  InternalPrint (LC_CONSOLE_DEBUG, text);
}

void Console::PrintWarning (const char* format, ...)
{
  char text[512];
  va_list args;

  va_start (args, format);
  vsprintf (text, format, args);
  va_end (args);

  InternalPrint (LC_CONSOLE_WARNING, text);
}

void Console::PrintError (const char* format, ...)
{
  char text[512];
  va_list args;

  va_start (args, format);
  vsprintf (text, format, args);
  va_end (args);

  InternalPrint (LC_CONSOLE_ERROR, text);
}

void Console::InternalPrint (LC_CONSOLE_LEVEL level, const char* text)
{
#ifndef LC_DEBUG
  if (level == LC_CONSOLE_DEBUG)
    return;
#endif

  if (m_pWindowFunc)
    (*m_pWindowFunc) (level, text, m_pWindowFuncData);
}