Skip to content

Commit

Permalink
3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Apr 17, 2023
1 parent 6fb9ff4 commit 52d1f59
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if(USE_CLANG)
endif(USE_CLANG)


project (logfilegen VERSION 3.0.2 LANGUAGES CXX)
project (logfilegen VERSION 3.0.3 LANGUAGES CXX)
add_definitions(-DVERSION_NUMBER="\\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\\"")
Expand Down
7 changes: 6 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
3.0.3
* @seq macro fix. Syntax change!
Was: @seq:param1|param2|etc
Now: @seq:param1^param2^etc

3.0.2
* @seq macros fix. Syntax change!
* @seq macro fix. Syntax change!
Was: @seq:param1:param2:etc
Now: @seq:param1|param2|etc

Expand Down
8 changes: 4 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
logfilegen 3.0.0
logfilegen 3.0.3

This release introduces the multithread support (performance improved), fixes mac and win building, and many more.

upd 3.0.1
* @meta macro fixes
* randomizer code has been rewritten
upd 3.0.2
upd 3.0.3
* @seq macros fix. Syntax change!
Was: @seq:param1:param2:etc
Now: @seq:param1|param2|etc
Was: @seq:param1|param2|etc
Now: @seq:param1^param2^etc
6 changes: 3 additions & 3 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ Please note, the file name after ```@file``` must be an absolute file path, or,

#### @seq

Works like **sequence** variable values. Each value is separated by ```|```.
Works like **sequence** variable values. Each value is separated by ```^```.

Syntax: ```@seq:param1|param2|etc```
Syntax: ```@seq:param1^param2^etc```

Example:

```
$test=@seq:GET|PUT
$test=@seq:GET^PUT
$logstring=hello, $test
```

Expand Down
56 changes: 47 additions & 9 deletions macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,43 @@ vector <string> split_string_to_vector_a (const string &s, char delimeter, char
}


vector <string> split_string_to_vector_simple (const string &s, char delimeter)
{
vector <string> result;

size_t a = 0;
size_t b = 0;

while (b < s.size())
{
if (b + 1 == s.size())
{
string t = s.substr (a + 1, b - a);
result.push_back (t);
}

if (s[b] == delimeter)
// if (b + 1 != s.size())
// if (s[b + 1] != aware)
{
string t;

if (a == 0)
t = s.substr (a, b - a);
else
t = s.substr (a + 1, b - a - 1);

result.push_back (t);
a = b;
}

b++;
}

return result;
}


void CMacroSeq::parse (const string &s)
{
// cout << "void CMacroSeq::parse: " << s << endl;
Expand All @@ -495,22 +532,23 @@ void CMacroSeq::parse (const string &s)
length = 0;
text = "";

size_t pos = s.find_first_of ("|");
if (pos == std::string::npos)
return;


// vt = split_string_to_vector_a (s, ':', '/');

pos = s.find_first_of (":");
size_t pos = s.find_first_of (":");
if (pos == std::string::npos)
return;

std::string t = s.substr (pos);
std::string t = s.substr (pos + 1);

// cout << "t: " << t << endl;


// vt = split_string_to_vector_simple (t, '^');
vt = split_string_to_vector (t, "^");

// cout << "t: " << t << endl;

vt = split_string_to_vector (t, "|");
// vt = split_string_to_vector (t, "|");

// vt = split_string_to_vector (s, ":");
}
Expand All @@ -525,7 +563,7 @@ string CMacroSeq::process()
if (vt.size() == 0)
return string();

size_t i = get_rnd (1, vt.size() - 1);
size_t i = get_rnd (0, vt.size() - 1);

// cout << "CMacroSeq::process() 2:" << i << endl;

Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@


#ifndef VERSION_NUMBER
#define VERSION_NUMBER "3.0.2"
#define VERSION_NUMBER "3.0.3"
#endif


Expand Down Expand Up @@ -79,7 +79,7 @@ std::string find_config_in_paths (const std::string &fname)

void show_version()
{
std::cout << "logfilegen v." << VERSION_NUMBER << std::endl;
std::cout << "logfilegen v" << VERSION_NUMBER << std::endl;
}


Expand Down
2 changes: 1 addition & 1 deletion tpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ CTpl::CTpl (const string &fname, const string &amode)
vars.insert (std::make_pair ("%t", new CVar ("%t", "@datetime:%d/%b/%Y:%H:%M:%S %z")));

//$request $uri $protocol
vars.insert (std::make_pair ("%r", new CVar ("%r", "@meta:(@seq:/GET|/PUT) (@path:1:5:3) (@seq:HTTP/1.1|/HTTP/2.0)")));
vars.insert (std::make_pair ("%r", new CVar ("%r", "@meta:(@seq:/GET^/PUT) (@path:1:5:3) (@seq:HTTP/1.1^/HTTP/2.0)")));

vars.insert (std::make_pair ("%>s", new CVar ("%>s", "200|400")));
vars.insert (std::make_pair ("%b", new CVar ("%b", "1..9999")));
Expand Down

0 comments on commit 52d1f59

Please sign in to comment.