Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Apr 10, 2023
1 parent e086867 commit 6fb9ff4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 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.1 LANGUAGES CXX)
project (logfilegen VERSION 3.0.2 LANGUAGES CXX)
add_definitions(-DVERSION_NUMBER="\\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\\"")


Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.0.2
* @seq macros fix. Syntax change!
Was: @seq:param1:param2:etc
Now: @seq:param1|param2|etc

3.0.1
* @meta fix
* randomizer rewrote
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ This release introduces the multithread support (performance improved), fixes ma
upd 3.0.1
* @meta macro fixes
* randomizer code has been rewritten
upd 3.0.2
* @seq macros fix. Syntax change!
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
19 changes: 18 additions & 1 deletion macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,24 @@ 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, ':', '/');
vt = split_string_to_vector (s, ":");

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

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

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

vt = split_string_to_vector (t, "|");

// vt = split_string_to_vector (s, ":");
}


Expand All @@ -508,6 +522,9 @@ string CMacroSeq::process()

//cout << "vt.size(): " << vt.size() << endl;

if (vt.size() == 0)
return string();

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

// cout << "CMacroSeq::process() 2:" << i << endl;
Expand Down
2 changes: 1 addition & 1 deletion 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.1"
#define VERSION_NUMBER "3.0.2"
#endif


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 6fb9ff4

Please sign in to comment.