summaryrefslogtreecommitdiff
path: root/source/utilities/Logger.cpp
blob: d0370d617919c74c62f05fd1ddd66170ae744d4f (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
/*******************************************************************************
 * Copyright (C) ST-Ericsson SA 2011
 * License terms: 3-clause BSD license
 ******************************************************************************/

#include "Logger.h"
using namespace std;

#ifdef _WIN32
#define flockfile _lock_file
#define funlockfile _unlock_file
#else
#include <cstddef>
#include "OS.h"
#endif

Logger::Logger(const void *communication): communication_(communication), messageCallback_(0)
{
}

void Logger::log(const char *format, ...)
{
#ifdef _MESSAGES

    if (0 != messageCallback_) {
        CLockCS lock(criticalSection_);
        va_list args;
        char message[1024];
        va_start(args, format);
        vsprintf_s(message, format, args);
        va_end(args);
        messageCallback_(communication_, strlen(message), message);
    }

#endif
}