Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package logfilegen for openSUSE:Factory checked in at 2023-04-09 18:41:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/logfilegen (Old) and /work/SRC/openSUSE:Factory/.logfilegen.new.19717 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "logfilegen" Sun Apr 9 18:41:30 2023 rev:10 rq:1078164 version:3.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/logfilegen/logfilegen.changes 2023-04-08 17:39:49.258306751 +0200 +++ /work/SRC/openSUSE:Factory/.logfilegen.new.19717/logfilegen.changes 2023-04-09 18:43:27.702581280 +0200 @@ -1,0 +2,6 @@ +Sun Apr 9 10:18:35 UTC 2023 - Andreas Stieger <andreas.stie...@gmx.de> + +- logfilegen 3.0.1: + * macro fixes and randomizer code improvements + +------------------------------------------------------------------- Old: ---- logfilegen-3.0.0.tar.gz New: ---- logfilegen-3.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ logfilegen.spec ++++++ --- /var/tmp/diff_new_pack.P1Gzbx/_old 2023-04-09 18:43:28.114583611 +0200 +++ /var/tmp/diff_new_pack.P1Gzbx/_new 2023-04-09 18:43:28.118583633 +0200 @@ -18,7 +18,7 @@ Name: logfilegen -Version: 3.0.0 +Version: 3.0.1 Release: 0 Summary: Log file generator for server log files and user-defined formats License: Unlicense ++++++ logfilegen-3.0.0.tar.gz -> logfilegen-3.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/CMakeLists.txt new/logfilegen-3.0.1/CMakeLists.txt --- old/logfilegen-3.0.0/CMakeLists.txt 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/CMakeLists.txt 2023-04-09 11:30:15.000000000 +0200 @@ -13,7 +13,7 @@ endif(USE_CLANG) -project (logfilegen VERSION 3.0.0 LANGUAGES CXX) +project (logfilegen VERSION 3.0.1 LANGUAGES CXX) add_definitions(-DVERSION_NUMBER="\\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\\"") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/ChangeLog new/logfilegen-3.0.1/ChangeLog --- old/logfilegen-3.0.0/ChangeLog 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/ChangeLog 2023-04-09 11:30:15.000000000 +0200 @@ -1,3 +1,8 @@ +3.0.1 +* @meta fix +* randomizer rewrote + +3.0.0 + multithread support * win and mac support fixed - prometheus_cpp library support (logfilegen built-in code covers all needs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/NEWS new/logfilegen-3.0.1/NEWS --- old/logfilegen-3.0.0/NEWS 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/NEWS 2023-04-09 11:30:15.000000000 +0200 @@ -1,3 +1,7 @@ logfilegen 3.0.0 -This release introduces the multithread support (performance improved), fixes mac and win building, and many more. \ No newline at end of file +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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/cycle.cpp new/logfilegen-3.0.1/cycle.cpp --- old/logfilegen-3.0.0/cycle.cpp 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/cycle.cpp 2023-04-09 11:30:15.000000000 +0200 @@ -139,6 +139,7 @@ tpl = new CTpl (fname, params->mode); + fname_template = fname; log_current_size = 0; no_free_space = false; @@ -156,7 +157,7 @@ logrotator = new CLogRotator (params->logfile, params->max_log_files, string_to_file_size (params->max_log_file_size)); logrotator->use_gzip = params->use_gzip; - std::signal (SIGINT, f_signal_handler); + std::signal (SIGINT, f_signal_handler); if (! params->bstdout) @@ -186,7 +187,6 @@ server_init(); - } //http://localhost:8888/metrics diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/macro.cpp new/logfilegen-3.0.1/macro.cpp --- old/logfilegen-3.0.0/macro.cpp 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/macro.cpp 2023-04-09 11:30:15.000000000 +0200 @@ -7,17 +7,6 @@ #include <chrono> -#ifdef USE_PROM - -#include "prometheus/client_metric.h" -#include "prometheus/counter.h" -#include "prometheus/exposer.h" -#include "prometheus/family.h" -#include "prometheus/info.h" -#include "prometheus/registry.h" - -#endif - #include "utl.h" #include "macro.h" @@ -27,6 +16,15 @@ char arr_nums [] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; +std::mt19937 rnd_mt19937; + + +void rnd_init() +{ + rnd_mt19937.seed (std::chrono::system_clock::now().time_since_epoch().count()); +} + +/* std::mt19937 &mt() { // initialize once per thread @@ -38,12 +36,12 @@ return smt; } - +*/ int get_rnd (int ta, int tb) { std::uniform_int_distribution <> distrib (ta, tb); - return distrib (mt()); + return distrib (rnd_mt19937); } @@ -56,7 +54,7 @@ for (size_t i = 0; i < len; i++) { - int g = distrib (mt()); + int g = distrib (rnd_mt19937); char d = static_cast<char> (g + 'a'); result += d; } @@ -72,11 +70,11 @@ std::uniform_int_distribution<> distrib (0, 25); std::uniform_int_distribution<> dminmax (min, max); - size_t len = dminmax (mt()); + size_t len = dminmax (rnd_mt19937); for (size_t i = 0; i < len; i++) { - int g = distrib (mt()); + int g = distrib (rnd_mt19937); char d = static_cast<char> (g + 'a'); result += d; } @@ -113,7 +111,7 @@ for (size_t i = 0; i < len; i++) { - result += arr_nums[distrib (mt())]; + result += arr_nums[distrib (rnd_mt19937)]; } return result; @@ -124,14 +122,14 @@ { std::uniform_int_distribution<> distrib (0, 9); std::uniform_int_distribution<> dminmax (min, max); - size_t len = dminmax (mt()); + size_t len = dminmax (rnd_mt19937); string result; result.reserve (len); for (size_t i = 0; i < len; i++) { - result += arr_nums[distrib (mt())]; + result += arr_nums[distrib (rnd_mt19937)]; } return result; @@ -147,7 +145,7 @@ for (size_t i = 0; i < len; i++) { - result += arr_nums[distrib (mt())]; + result += arr_nums[distrib (rnd_mt19937)]; } return result; @@ -158,14 +156,14 @@ { std::uniform_int_distribution<> distrib (0, 15); std::uniform_int_distribution<> dminmax (min, max); - size_t len = dminmax (mt()); + size_t len = dminmax (rnd_mt19937); string result; result.reserve (len); for (size_t i = 0; i < len; i++) { - result += arr_nums[distrib (mt())]; + result += arr_nums[distrib (rnd_mt19937)]; } return result; @@ -245,16 +243,16 @@ string result; result.reserve (16); - result += to_string (distrib (mt())); + result += to_string (distrib (rnd_mt19937)); result += "."; - result += to_string (distrib (mt())); + result += to_string (distrib (rnd_mt19937)); result += "."; - result += to_string (distrib (mt())); + result += to_string (distrib (rnd_mt19937)); result += "."; - result += to_string (distrib (mt())); + result += to_string (distrib (rnd_mt19937)); return result; } @@ -439,7 +437,7 @@ string CMacroPathRandom::process() { - return gen_rnd_path (len_min, len_max, length); + return gen_rnd_path (len_min, len_max, length); } @@ -490,19 +488,34 @@ void CMacroSeq::parse (const string &s) { +// cout << "void CMacroSeq::parse: " << s << endl; + len_min = 0; len_max = 0; length = 0; text = ""; - vt = split_string_to_vector_a (s, ':', '/'); +// vt = split_string_to_vector_a (s, ':', '/'); + vt = split_string_to_vector (s, ":"); + + } string CMacroSeq::process() { +// cout << "CMacroSeq::process() 1" << endl; + + //cout << "vt.size(): " << vt.size() << endl; + size_t i = get_rnd (1, vt.size() - 1); + // cout << "CMacroSeq::process() 2:" << i << endl; + + +// cout << "CMacroSeq::process() 3" << endl; + + return vt[i]; } @@ -550,6 +563,8 @@ void CMacroMeta::parse (const string &s) { +// cout << "CMacroMeta::parse" << endl; + len_min = 0; len_max = 0; length = 0; @@ -605,7 +620,7 @@ //create cached macro string name = get_macro_name (macrotext); - // cout << "and name is: " << name << endl; + // cout << "name is: " << name << endl; if (name.empty()) continue; @@ -616,6 +631,7 @@ //copy metamacro instead of real one string newname = "@" + to_string(i); + // cout << "new name is: " << newname << endl; meta += newname; @@ -628,6 +644,10 @@ meta += text[i]; i++; } + + // cout << "CMacroMeta::parse -2" << endl; + + } @@ -639,7 +659,11 @@ for (it = cache.macros.begin(); it != cache.macros.end(); it++) { string macroname = it->first; //@1, @2, etc - // cout << "macroname:" << macroname << endl; + +// cout << "CMacroMeta::parse" << endl; + + + //cout << "macroname:" << macroname << endl; size_t i = 0; do { @@ -654,6 +678,7 @@ return text; } + void CMacrosCache::add (size_t pos, CMacro *m) { macros.insert (std::make_pair (pos, m)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/macro.h new/logfilegen-3.0.1/macro.h --- old/logfilegen-3.0.0/macro.h 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/macro.h 2023-04-09 11:30:15.000000000 +0200 @@ -7,6 +7,8 @@ #include <map> + + class CMacro { public: @@ -184,4 +186,6 @@ }; +void rnd_init(); + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/main.cpp new/logfilegen-3.0.1/main.cpp --- old/logfilegen-3.0.0/main.cpp 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/main.cpp 2023-04-09 11:30:15.000000000 +0200 @@ -41,7 +41,7 @@ #ifndef VERSION_NUMBER -#define VERSION_NUMBER "3.0.0" +#define VERSION_NUMBER "3.0.1" #endif @@ -139,6 +139,7 @@ std::string tdir = get_tmp_dir(); + rnd_init(); std::string temp_logfile; std::string temp_logfile0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/tpl.cpp new/logfilegen-3.0.1/tpl.cpp --- old/logfilegen-3.0.0/tpl.cpp 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/tpl.cpp 2023-04-09 11:30:15.000000000 +0200 @@ -75,9 +75,10 @@ } + //logstrings["apache"] = "\"%h %l %u %t \"%r\" %>s %b\""; - if (mode == "apache") + if (mode == "apache") { vars.insert (std::make_pair ("$logstring", new CVar ("$logstring", logstrings["apache"]))); @@ -85,17 +86,21 @@ vars.insert (std::make_pair ("%l", new CVar ("%l", "@str:8|-"))); vars.insert (std::make_pair ("%u", new CVar ("%u", "@str:8|-"))); vars.insert (std::make_pair ("%t", new CVar ("%t", "@datetime:%d/%b/%Y:%H:%M:%S %z"))); -// vars.insert (std::make_pair ("%r", new CVar ("%r", "/GET /hello.html HTTP/1.1."))); - vars.insert (std::make_pair ("%r", new CVar ("%r", "@meta:(@seq:/GET:/PUT) (@path:1:5:3) (@seq:HTTP/1.1:/HTTP/2.0)"))); //$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 ("%>s", new CVar ("%>s", "200|400"))); vars.insert (std::make_pair ("%b", new CVar ("%b", "1..9999"))); + + + // vars.insert (std::make_pair ("%r", new CVar ("%r", "/GET /hello.html HTTP/1.1."))); + } + for (map <string, string>::const_iterator it = pf->values.begin(); it != pf->values.end(); it++) { auto f = vars.find (it->first); @@ -108,21 +113,30 @@ vars.insert (std::make_pair (it->first, new CVar (it->first, it->second))); } + } string CTpl::prepare_log_string() { +// std::cout << "111" << std::endl; + + string logstring = vars["$logstring"]->get_val(); logstring.reserve (256); +// std::cout << "222:" << logstring << std::endl; + + if (logstring.empty()) { cout << "$logstring mandatory variable is not defined!" << endl; return ""; } + + //change to for (auto it = mymap.rbegin(); it != mymap.rend(); it++) map <string, CVar*>::reverse_iterator it; for (it = vars.rbegin(); it != vars.rend(); it++) @@ -139,5 +153,7 @@ while (i != string::npos); } + + return logstring; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logfilegen-3.0.0/vars.cpp new/logfilegen-3.0.1/vars.cpp --- old/logfilegen-3.0.0/vars.cpp 2023-04-08 14:24:26.000000000 +0200 +++ new/logfilegen-3.0.1/vars.cpp 2023-04-09 11:30:15.000000000 +0200 @@ -15,7 +15,9 @@ using namespace std; +extern std::mt19937 rnd_mt19937; +/* std::mt19937 &vmt() { // initialize once per thread @@ -28,7 +30,7 @@ return smt; } - +*/ int get_value_nature (const string &s) @@ -136,7 +138,7 @@ int CVar::get_rnd (int ta, int tb) { std::uniform_int_distribution <> distrib (ta, tb); - return distrib (vmt()); + return distrib (rnd_mt19937); } @@ -148,7 +150,7 @@ std::stringstream sstream; sstream.setf (std::ios::fixed); sstream.precision (precision); - sstream << distrib (vmt()); + sstream << distrib (rnd_mt19937); return sstream.str(); }