forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fw-logs-formating-options.cpp
92 lines (79 loc) · 2.44 KB
/
fw-logs-formating-options.cpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
#include "fw-logs-formating-options.h"
#include "fw-logs-xml-helper.h"
#include <sstream>
using namespace std;
namespace fw_logger
{
fw_log_event::fw_log_event()
: num_of_params(0),
line("")
{}
fw_log_event::fw_log_event(int input_num_of_params, const string& input_line)
: num_of_params(input_num_of_params),
line(input_line)
{}
fw_logs_formating_options::fw_logs_formating_options(const string& xml_full_file_path)
: _xml_full_file_path(xml_full_file_path)
{}
fw_logs_formating_options::~fw_logs_formating_options(void)
{
}
bool fw_logs_formating_options::get_event_data(int id, fw_log_event* log_event_data) const
{
auto event_it = _fw_logs_event_list.find(id);
if (event_it != _fw_logs_event_list.end())
{
*log_event_data = event_it->second;
return true;
}
else
{
stringstream ss;
ss << "*** Unrecognized Log Id: ";
ss << id;
ss << "! P1 = 0x{0:x}, P2 = 0x{1:x}, P3 = 0x{2:x}";
log_event_data->line = ss.str();
log_event_data->num_of_params = 3;
return false;
}
}
bool fw_logs_formating_options::get_file_name(int id, string* file_name) const
{
auto file_it = _fw_logs_file_names_list.find(id);
if (file_it != _fw_logs_file_names_list.end())
{
*file_name = file_it->second;
return true;
}
else
{
*file_name = "Unknown";
return false;
}
}
bool fw_logs_formating_options::get_thread_name(uint32_t thread_id, string* thread_name) const
{
auto file_it = _fw_logs_thread_names_list.find(thread_id);
if (file_it != _fw_logs_thread_names_list.end())
{
*thread_name = file_it->second;
return true;
}
else
{
*thread_name = "Unknown";
return false;
}
}
std::unordered_map<string, std::vector<kvp>> fw_logs_formating_options::get_enums() const
{
return _fw_logs_enum_names_list;
}
bool fw_logs_formating_options::initialize_from_xml()
{
fw_logs_xml_helper fw_logs_xml(_xml_full_file_path);
return fw_logs_xml.build_log_meta_data(this);
}
}