Commit 1ac2fe0b authored by Pavel Vainerman's avatar Pavel Vainerman

(LogSession): добавил логов

(codegen): добавил вывод информации о LogServer-е
parent 5653c604
......@@ -494,6 +494,8 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo( CORBA:
inf &lt;&lt; i->info &lt;&lt; endl;
inf &lt;&lt; "LogServer: " &lt;&lt; logserv_host &lt;&lt; ":" &lt;&lt; logserv_port &lt;&lt; endl;
if( logserv /* &amp;&amp; userparam &lt; 0 */ )
inf &lt;&lt; " " &lt;&lt; logserv->getShortInfo() &lt;&lt; endl;
inf &lt;&lt; dumpIO() &lt;&lt; endl;
inf &lt;&lt; endl;
auto timers = getTimersList();
......
......@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.5
Release: alt15
Release: alt16
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
......@@ -486,6 +486,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Tue Sep 27 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt16
- LogSession: add more logs
- codegen: add logserver information in getInfo()
* Tue Sep 20 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt15
- up build
......
......@@ -255,7 +255,12 @@ string LogServer::getShortInfo()
{
ostringstream inf;
inf << "LogServer: " << myname << endl;
inf << "LogServer: " << myname
<< " ["
<< " sessMaxCount=" << sessMaxCount
<< " ]"
<< endl;
{
uniset_rwmutex_wrlock l(mutSList);
......
......@@ -74,7 +74,7 @@ LogSession::LogSession( const Poco::Net::StreamSocket& s, std::shared_ptr<DebugS
if( iaddr.host().toString().empty() )
{
ostringstream err;
err << "(ModbusTCPSession): unknonwn ip(0.0.0.0) client disconnected?!";
err << "(LogSession): unknonwn ip(0.0.0.0) client disconnected?!";
if( mylog.is_crit() )
mylog.crit() << err.str() << endl;
......@@ -107,7 +107,7 @@ LogSession::LogSession( const Poco::Net::StreamSocket& s, std::shared_ptr<DebugS
if( log )
conn = log->signal_stream_event().connect( sigc::mem_fun(this, &LogSession::logOnEvent) );
else
mylog.crit() << "LOG NULL!!" << endl;
mylog.crit() << "(LogSession): LOG NULL!!" << endl;
}
// -------------------------------------------------------------------------
void LogSession::logOnEvent( const std::string& s ) noexcept
......@@ -141,7 +141,7 @@ void LogSession::logOnEvent( const std::string& s ) noexcept
if( !lostMsg )
{
ostringstream err;
err << "The buffer is full. Message is lost...(size of buffer " << maxRecordsNum << ")" << endl;
err << "(LogSession): The buffer is full. Message is lost...(size of buffer " << maxRecordsNum << ")" << endl;
logbuf.emplace(new UTCPCore::Buffer(std::move(err.str())));
lostMsg = true;
}
......@@ -163,7 +163,7 @@ void LogSession::run( const ev::loop_ref& loop ) noexcept
setSessionLogLevel(Debug::ANY);
if( mylog.is_info() )
mylog.info() << peername << "(run): run session.." << endl;
mylog.info() << peername << "(LogSession::run): run session.." << endl;
asyncEvent.set(loop);
cmdTimer.set(loop);
......@@ -178,7 +178,7 @@ void LogSession::run( const ev::loop_ref& loop ) noexcept
void LogSession::terminate()
{
if( mylog.is_info() )
mylog.info() << peername << "(terminate)..." << endl;
mylog.info() << peername << "(LogSession::terminate)..." << endl;
cancelled = true;
......@@ -196,6 +196,7 @@ void LogSession::terminate()
logbuf.pop();
}
sock->disconnect();
sock->close();
final();
}
......@@ -205,7 +206,7 @@ void LogSession::event( ev::async& watcher, int revents ) noexcept
if( EV_ERROR & revents )
{
if( mylog.is_crit() )
mylog.crit() << peername << "(event): EVENT ERROR.." << endl;
mylog.crit() << peername << "(LogSession::event): EVENT ERROR.." << endl;
return;
}
......@@ -218,7 +219,7 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
if( EV_ERROR & revents )
{
if( mylog.is_crit() )
mylog.crit() << peername << "(callback): EVENT ERROR.." << endl;
mylog.crit() << peername << "(LogSession::callback): EVENT ERROR.." << endl;
return;
}
......@@ -241,10 +242,10 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
catch(...){}
}
if( cancelled )
if( cancelled.load() )
{
if( mylog.is_info() )
mylog.info() << peername << ": stop session... disconnect.." << endl;
mylog.info() << peername << "LogSession: stop session... disconnect.." << endl;
io.stop();
cmdTimer.stop();
......@@ -262,7 +263,7 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
// -------------------------------------------------------------------------
void LogSession::writeEvent( ev::io& watcher )
{
if( cancelled )
if( cancelled.load() )
return;
UTCPCore::Buffer* buffer = 0;
......@@ -283,17 +284,17 @@ void LogSession::writeEvent( ev::io& watcher )
if( !buffer )
return;
ssize_t ret = write(watcher.fd, buffer->dpos(), buffer->nbytes());
ssize_t ret = ::write(watcher.fd, buffer->dpos(), buffer->nbytes());
if( ret < 0 )
{
if( mylog.is_warn() )
mylog.warn() << peername << "(writeEvent): write to socket error(" << errno << "): " << strerror(errno) << endl;
mylog.warn() << peername << "(LogSession::writeEvent): write to socket error(" << errno << "): " << strerror(errno) << endl;
if( errno == EPIPE )
if( errno == EPIPE || errno == EBADF )
{
if( mylog.is_warn() )
mylog.warn() << peername << "(writeEvent): write error.. terminate session.." << endl;
mylog.warn() << peername << "(LogSession::writeEvent): write error.. terminate session.." << endl;
cancelled = true;
}
......@@ -344,7 +345,7 @@ size_t LogSession::readData( unsigned char* buf, int len )
if( res < 0 )
{
if( errno != EAGAIN && mylog.is_warn() )
mylog.warn() << peername << "(readData): read from socket error(" << errno << "): " << strerror(errno) << endl;
mylog.warn() << peername << "(LogSession::readData): read from socket error(" << errno << "): " << strerror(errno) << endl;
return 0;
}
......@@ -362,7 +363,7 @@ size_t LogSession::readData( unsigned char* buf, int len )
}
mylog.info() << peername << "(readData): client disconnected.." << endl;
mylog.info() << peername << "(LogSession::readData): client disconnected.." << endl;
cancelled = true;
return 0;
}
......@@ -382,13 +383,13 @@ void LogSession::readEvent( ev::io& watcher ) noexcept
if( ret != sizeof(msg) || msg.magic != LogServerTypes::MAGICNUM )
{
if( mylog.is_warn() )
mylog.warn() << peername << "(readEvent): BAD MESSAGE..." << endl;
mylog.warn() << peername << "(LogSession::readEvent): BAD MESSAGE..." << endl;
return;
}
if( mylog.is_info() )
mylog.info() << peername << "(readEvent): receive command: '" << msg.cmd << "'" << endl;
mylog.info() << peername << "(LogSession::readEvent): receive command: '" << msg.cmd << "'" << endl;
string cmdLogName(msg.logname);
......@@ -399,7 +400,7 @@ void LogSession::readEvent( ev::io& watcher ) noexcept
catch( std::exception& ex )
{
if( mylog.is_warn() )
mylog.warn() << peername << "(readEvent): " << ex.what() << endl;
mylog.warn() << peername << "(LogSession::readEvent): " << ex.what() << endl;
}
catch(...){}
......@@ -550,7 +551,7 @@ void LogSession::cmdProcessing( const string& cmdLogName, const LogServerTypes::
catch( std::exception& ex )
{
if( mylog.is_warn() )
mylog.warn() << peername << "(cmdProcessing): " << ex.what() << endl;
mylog.warn() << peername << "(LogSession::cmdProcessing): " << ex.what() << endl;
}
}
// -------------------------------------------------------------------------
......@@ -559,7 +560,7 @@ void LogSession::onCmdTimeout( ev::timer& watcher, int revents ) noexcept
if( EV_ERROR & revents )
{
if( mylog.is_crit() )
mylog.crit() << peername << "(onCmdTimeout): EVENT ERROR.." << endl;
mylog.crit() << peername << "(LogSession::onCmdTimeout): EVENT ERROR.." << endl;
return;
}
......@@ -573,7 +574,7 @@ void LogSession::onCheckConnectionTimer( ev::timer& watcher, int revents ) noexc
if( EV_ERROR & revents )
{
if( mylog.is_crit() )
mylog.crit() << peername << "(onCheckConnectionTimer): EVENT ERROR.." << endl;
mylog.crit() << peername << "(LogSession::onCheckConnectionTimer): EVENT ERROR.." << endl;
return;
}
......
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