blob: baeed551df6fa6cdc1a34f5806adb77e51412fc1 (
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
|
#include "util/logger.h"
// NOTE(uklotzde): The initialization of Logger must not depend on any
// static data, because Logger instances are usually instantiated as
// static instances within other compilation units. The order of static
// initializations across compilation units is undefined!!
namespace {
inline QByteArray preambleChars(const QLatin1String& logContext) {
QByteArray preamble;
const int logContextLen = logContext.size();
if (logContextLen > 0) {
const QLatin1String preambleSuffix(" -");
const int preambleSuffixLen = preambleSuffix.size();
preamble.reserve(logContextLen + preambleSuffixLen);
preamble.append(logContext.latin1(), logContextLen);
preamble.append(preambleSuffix.latin1(), preambleSuffixLen);
}
return preamble;
}
} // anonymous namespace
namespace mixxx {
Logger::Logger(const char* logContext)
: m_preambleChars(preambleChars(QLatin1String(logContext))) {
}
Logger::Logger(const QLatin1String& logContext)
: m_preambleChars(preambleChars(logContext)) {
}
} // namespace mixxx
|