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
|
// **********************************************************************
//
// Copyright (c) 2003-present ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifdef ICE_USE_SYSTEMD
#include <Ice/SystemdJournalI.h>
#include <Ice/LocalException.h>
#include <syslog.h>
#include <systemd/sd-journal.h>
using namespace std;
using namespace Ice;
using namespace IceInternal;
Ice::SystemdJournalI::SystemdJournalI(const string& prefix) :
_prefix(prefix)
{
}
void
Ice::SystemdJournalI::print(const string& message)
{
write(LOG_INFO, message);
}
void
Ice::SystemdJournalI::trace(const string& category, const string& message)
{
write(LOG_INFO, category + ": " + message);
}
void
Ice::SystemdJournalI::warning(const string& message)
{
write(LOG_WARNING, message);
}
void
Ice::SystemdJournalI::error(const string& message)
{
write(LOG_ERR, message);
}
string
Ice::SystemdJournalI::getPrefix()
{
return _prefix;
}
Ice::LoggerPtr
Ice::SystemdJournalI::cloneWithPrefix(const string& prefix)
{
return ICE_MAKE_SHARED(SystemdJournalI, prefix);
}
void
Ice::SystemdJournalI::write(int priority, const string& message) const
{
sd_journal_send("MESSAGE=%s", message.c_str(),
"PRIORITY=%i", priority,
"SYSLOG_IDENTIFIER=%s", _prefix.c_str(),
NULL); // Using NULL is necessary for EL7, see #293
}
#endif
|