Skip to content

Commit e73d284

Browse files
committed
Merge
2 parents 5d0f7b3 + 22bfa84 commit e73d284

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

components/core/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
77
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
88
endif()
99

10+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
11+
1012
# Set general compressor
1113
set(GENERAL_COMPRESSOR "zstd" CACHE STRING "The general-purpose compressor used as the 2nd-stage compressor")
1214
set_property(CACHE GENERAL_COMPRESSOR PROPERTY STRINGS passthrough zstd)

components/core/src/EncodedVariableInterpreter.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ bool EncodedVariableInterpreter::decode_variables_into_message (const LogTypeDic
319319
var_dict_id = decode_var_dict_id(encoded_vars[i]);
320320
decompressed_msg += var_dict.get_value(var_dict_id);
321321
break;
322+
case ir::VariablePlaceholder::Escape:
323+
break;
322324
default:
323325
SPDLOG_ERROR(
324326
"EncodedVariableInterpreter: Logtype '{}' contains "

components/core/src/LogTypeDictionaryEntry.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,25 @@ void LogTypeDictionaryEntry::add_float_var () {
4646
add_float_var(m_value);
4747
}
4848

49+
void LogTypeDictionaryEntry::add_escape_var() {
50+
m_var_positions.push_back(m_value.length());
51+
add_escape_var(m_value);
52+
}
53+
4954
bool LogTypeDictionaryEntry::parse_next_var (const string& msg, size_t& var_begin_pos, size_t& var_end_pos, string& var) {
5055
auto last_var_end_pos = var_end_pos;
5156
if (ir::get_bounds_of_next_var(msg, var_begin_pos, var_end_pos)) {
5257
// Append to log type: from end of last variable to start of current variable
53-
add_constant(msg, last_var_end_pos, var_begin_pos - last_var_end_pos);
58+
auto constant = std::string_view(msg).substr(last_var_end_pos, var_begin_pos - last_var_end_pos);
59+
ir::escape_and_append_constant_to_logtype(constant, m_value);
5460

5561
var.assign(msg, var_begin_pos, var_end_pos - var_begin_pos);
5662
return true;
5763
}
5864
if (last_var_end_pos < msg.length()) {
5965
// Append to log type: from end of last variable to end
60-
add_constant(msg, last_var_end_pos, msg.length() - last_var_end_pos);
66+
auto constant = std::string_view(msg).substr(last_var_end_pos, msg.length() - last_var_end_pos);
67+
ir::escape_and_append_constant_to_logtype(constant, m_value);
6168
}
6269

6370
return false;
@@ -71,10 +78,8 @@ void LogTypeDictionaryEntry::clear () {
7178
void LogTypeDictionaryEntry::write_to_file (streaming_compression::Compressor& compressor) const {
7279
compressor.write_numeric_value(m_id);
7380

74-
string escaped_value;
75-
get_value_with_unfounded_variables_escaped(escaped_value);
76-
compressor.write_numeric_value<uint64_t>(escaped_value.length());
77-
compressor.write_string(escaped_value);
81+
compressor.write_numeric_value<uint64_t>(m_value.length());
82+
compressor.write_string(m_value);
7883
}
7984

8085
ErrorCode LogTypeDictionaryEntry::try_read_from_file (streaming_compression::Decompressor& decompressor) {
@@ -109,6 +114,9 @@ ErrorCode LogTypeDictionaryEntry::try_read_from_file (streaming_compression::Dec
109114
is_escaped = false;
110115
} else if (ir::cVariablePlaceholderEscapeCharacter == c) {
111116
is_escaped = true;
117+
add_constant(constant, 0, constant.length());
118+
constant.clear();
119+
add_escape_var();
112120
} else {
113121
if (enum_to_underlying_type(ir::VariablePlaceholder::Integer) == c) {
114122
add_constant(constant, 0, constant.length());

components/core/src/LogTypeDictionaryEntry.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ class LogTypeDictionaryEntry : public DictionaryEntry<logtype_dictionary_id_t> {
6363
static void add_float_var (std::string& logtype) {
6464
logtype += enum_to_underlying_type(ir::VariablePlaceholder::Float);
6565
}
66+
/**
67+
* Adds an escape variable placeholder to the given logtype
68+
* @param logtype
69+
*/
70+
static void add_escape_var (std::string& logtype) {
71+
logtype += enum_to_underlying_type(ir::VariablePlaceholder::Escape);
72+
}
6673

6774
size_t get_num_vars () const { return m_var_positions.size(); }
6875
/**
@@ -98,6 +105,10 @@ class LogTypeDictionaryEntry : public DictionaryEntry<logtype_dictionary_id_t> {
98105
* Adds a dictionary variable placeholder
99106
*/
100107
void add_dictionary_var ();
108+
/**
109+
* Adds an escape variable placeholder
110+
*/
111+
void add_escape_var ();
101112

102113
/**
103114
* Parses next variable from a message, constructing the constant part of the message's logtype as well

components/core/src/ir/parsing.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ enum class VariablePlaceholder : char {
1717
Integer = 0x11,
1818
Dictionary = 0x12,
1919
Float = 0x13,
20+
Escape = 0x5c,
2021
};
2122

2223
constexpr char cVariablePlaceholderEscapeCharacter = '\\';

0 commit comments

Comments
 (0)