File: debug.cc

package info (click to toggle)
sms-pl 1.9.2m-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 620 kB
  • ctags: 355
  • sloc: cpp: 2,143; ansic: 1,046; perl: 272; makefile: 113; sh: 97
file content (30 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (2)
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
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "debug.h"
#include "vsprintf.h"

void Debug::Open()
{
#ifdef DEBUG
     if (!str.is_open() && name != "") str.open(name.c_str());
#endif
}

void Debug::Log(int level, const char *msg, ...)
{
    Open();
    if (!str.is_open()) return;
    
    char buf[MAX_LOG_LINE_LEN];
    va_list args;

    va_start(args, msg);
    VSPRINTF(buf, sizeof(buf)-1, msg, args);
    va_end(args);

    str << buf << std::endl;
}