Commit 2abfbf40 authored by Pavel Vainerman's avatar Pavel Vainerman

(UNet): set default prefix for log setup (default: "--unet-log")

parent 112329df
......@@ -164,7 +164,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
}
unetinfo << myname << "(init): init sender.. my node " << n_it.getProp("name") << endl;
sender = make_shared<UNetSender>(h, p, shm, false, s_field, s_fvalue, prefix);
sender = make_shared<UNetSender>(h, p, shm, false, s_field, s_fvalue, "unet", prefix);
sender->setSendPause(sendpause);
sender->setCheckConnectionPause(checkConnectionPause);
loga->add(sender->getLog());
......@@ -326,7 +326,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
unetinfo << myname << "(init): (node='" << n << "') add basic receiver "
<< h << ":" << p << endl;
auto r = make_shared<UNetReceiver>(h, p, shm);
auto r = make_shared<UNetReceiver>(h, p, shm, false, prefix);
loga->add(r->getLog());
......@@ -358,7 +358,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
unetinfo << myname << "(init): (node='" << n << "') add reserv receiver "
<< h2 << ":" << p2 << endl;
r2 = make_shared<UNetReceiver>(h2, p2, shm);
r2 = make_shared<UNetReceiver>(h2, p2, shm, false, prefix);
loga->add(r2->getLog());
......
......@@ -40,7 +40,10 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs,
}
*/
// ------------------------------------------------------------------------------------------
UNetReceiver::UNetReceiver(const std::string& s_host, int _port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection ):
UNetReceiver::UNetReceiver(const std::string& s_host, int _port
, const std::shared_ptr<SMInterface>& smi
, bool nocheckConnection
, const std::string& prefix ):
shm(smi),
recvpause(10),
updatepause(100),
......@@ -71,11 +74,14 @@ UNetReceiver::UNetReceiver(const std::string& s_host, int _port, const std::shar
addr = s_host.c_str();
ostringstream logname;
logname << prefix << "-R-" << s_host << ":" << setw(4) << port;
unetlog = make_shared<DebugStream>();
unetlog->setLogName(myname);
unetlog->setLogName(logname.str());
auto conf = uniset_conf();
conf->initLogStream(unetlog, myname);
conf->initLogStream(unetlog, prefix + "-log");
upThread = unisetstd::make_unique< ThreadCreator<UNetReceiver> >(this, &UNetReceiver::updateThread);
......
......@@ -101,7 +101,9 @@ namespace uniset
public std::enable_shared_from_this<UNetReceiver>
{
public:
UNetReceiver( const std::string& host, int port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection = false );
UNetReceiver( const std::string& host, int port, const std::shared_ptr<SMInterface>& smi
, bool nocheckConnection = false
, const std::string& prefix = "unet" );
virtual ~UNetReceiver();
void start();
......
......@@ -31,10 +31,12 @@ namespace uniset
// -----------------------------------------------------------------------------
UNetSender::UNetSender(const std::string& _host, const int _port, const std::shared_ptr<SMInterface>& smi,
bool nocheckConnection, const std::string& s_f, const std::string& s_val,
const std::string& s_prefix, size_t maxDCount, size_t maxACount ):
const std::string& s_prefix,
const std::string& prefix,
size_t maxDCount, size_t maxACount ):
s_field(s_f),
s_fvalue(s_val),
prefix(s_prefix),
prop_prefix(s_prefix),
shm(smi),
port(_port),
s_host(_host),
......@@ -55,11 +57,14 @@ namespace uniset
myname = s.str();
}
ostringstream logname;
logname << prefix << "-S-" << s_host << "-" << port;
unetlog = make_shared<DebugStream>();
unetlog->setLogName(myname);
unetlog->setLogName(logname.str());
auto conf = uniset_conf();
conf->initLogStream(unetlog, myname);
conf->initLogStream(unetlog, prefix + "-log");
unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl;
......@@ -407,7 +412,7 @@ namespace uniset
return false;
}
int priority = it.getPIntProp(prefix + "_sendfactor", 0);
int priority = it.getPIntProp(prop_prefix + "_sendfactor", 0);
auto& pk = mypacks[priority];
......
......@@ -69,9 +69,14 @@ namespace uniset
class UNetSender
{
public:
UNetSender( const std::string& host, const int port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection = false,
const std::string& s_field = "", const std::string& s_fvalue = "", const std::string& prefix = "unet",
size_t maxDCount = UniSetUDP::MaxDCount, size_t maxACount = UniSetUDP::MaxACount );
UNetSender( const std::string& host, const int port, const std::shared_ptr<SMInterface>& smi
, bool nocheckConnection = false
, const std::string& s_field = ""
, const std::string& s_fvalue = ""
, const std::string& prop_prefix = "unet"
, const std::string& prefix = "unet"
, size_t maxDCount = UniSetUDP::MaxDCount
, size_t maxACount = UniSetUDP::MaxACount );
virtual ~UNetSender();
......@@ -175,7 +180,7 @@ namespace uniset
std::string s_field = { "" };
std::string s_fvalue = { "" };
std::string prefix = { "" };
std::string prop_prefix = { "" };
const std::shared_ptr<SMInterface> shm;
std::shared_ptr<DebugStream> unetlog;
......
......@@ -3,6 +3,6 @@
uniset2-start.sh -f ./uniset2-unetexchange --unet-name UNetExchange --unet-run-logserver \
--confile test.xml --smemory-id SharedMemory \
--unet-filter-field rs --unet-filter-value 2 --unet-maxdifferense 40 --unet-sendpause 1000 \
--dlog-add-levels info,crit,warn --unet-log-add-levels info,crit,warn,any $*
--dlog-add-levels info,crit,warn --unet-log-add-levels info,crit,warn,any --unet-S-localhost-3000-add-levels any $*
#--unet-nodes-confnode specnet
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment