-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDecodeHandler.cpp
More file actions
54 lines (43 loc) · 1.31 KB
/
DecodeHandler.cpp
File metadata and controls
54 lines (43 loc) · 1.31 KB
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
#include "DecodeHandler.h"
#include <opendnp3/logging/LogLevels.h>
#include <iostream>
using namespace std;
using namespace opendnp3;
DecodeHandler::DecodeHandler() : indent(0)
{
}
void DecodeHandler::log(ModuleId module, const char* id, LogLevel level, char const* location, char const* message)
{
auto clazz = GetClass(level);
cout << "<pre class=\"" << GetClass(level) << " indent" << indent << "\">" << std::endl;
cout << message << std::endl;
cout << "</pre>" << std::endl;
}
void DecodeHandler::PushIndent()
{
++indent;
}
void DecodeHandler::PopIndent()
{
--indent;
}
std::string DecodeHandler::GetClass(const LogLevel& level)
{
using namespace opendnp3::flags;
if (level == EVENT)
return "event";
else if (level == ERR || level == WARN)
return "error";
else if (level == APP_HEADER_RX || level == APP_HEADER_TX)
return "app-header";
else if (level == APP_OBJECT_RX || level == APP_OBJECT_TX)
return "app-object-header";
else if (level == APP_HEX_RX || level == APP_HEX_TX)
return "app-hex";
else if (level == LINK_RX || level == LINK_TX || level == LINK_RX_HEX || level == LINK_TX_HEX)
return "link";
else if (level == TRANSPORT_RX || level == TRANSPORT_TX)
return "transport";
else
return "unknown";
}