Commit dc1fabfe authored by Pavel Vainerman's avatar Pavel Vainerman

(2.0): рефакторинг DebugStream. unideb --> ulog, добавлены новые функции…

(2.0): рефакторинг DebugStream. unideb --> ulog, добавлены новые функции (is_xxx(), level1(), info() )
parent d357e85b
...@@ -27,3 +27,5 @@ codegen: ...@@ -27,3 +27,5 @@ codegen:
Version 2.0 Version 2.0
============ ============
- написать документацию по ModbusSlave - написать документацию по ModbusSlave
- рефакторинг класса логов (DebugStream)
- циклическое хранилище для аварийных следов на основе SQLite
...@@ -448,7 +448,7 @@ int omap() ...@@ -448,7 +448,7 @@ int omap()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
unideb[Debug::CRIT] << " configuration init FAILED!!! \n"; ulog.crit() << " configuration init FAILED!!! \n";
return 1; return 1;
} }
return 0; return 0;
......
...@@ -381,7 +381,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -381,7 +381,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK ); int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
if( fd <= 0 ) if( fd <= 0 )
{ {
dlog[Debug::WARN] << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl; dlog.warn() << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -393,7 +393,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -393,7 +393,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
int ret = ::read(fd,&buf,sizeof(buf)); int ret = ::read(fd,&buf,sizeof(buf));
if( ret < 0 ) if( ret < 0 )
{ {
dlog[Debug::WARN] << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl; dlog.warn() << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -407,7 +407,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -407,7 +407,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
struct stat fs; struct stat fs;
if( fstat(fd,&fs) < 0 ) if( fstat(fd,&fs) < 0 )
{ {
dlog[Debug::WARN] << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl; dlog.warn() << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -422,7 +422,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -422,7 +422,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) ) if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) )
{ {
dlog[Debug::WARN] << "(fileTransfer): set date failed..." << endl; dlog.warn() << "(fileTransfer): set date failed..." << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
......
...@@ -376,7 +376,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -376,7 +376,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK ); int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
if( fd <= 0 ) if( fd <= 0 )
{ {
dlog[Debug::WARN] << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl; dlog.warn() << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -388,7 +388,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -388,7 +388,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
int ret = ::read(fd,&buf,sizeof(buf)); int ret = ::read(fd,&buf,sizeof(buf));
if( ret < 0 ) if( ret < 0 )
{ {
dlog[Debug::WARN] << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl; dlog.warn() << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -402,7 +402,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -402,7 +402,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
struct stat fs; struct stat fs;
if( fstat(fd,&fs) < 0 ) if( fstat(fd,&fs) < 0 )
{ {
dlog[Debug::WARN] << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl; dlog.warn() << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -417,7 +417,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -417,7 +417,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) ) if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) )
{ {
dlog[Debug::WARN] << "(fileTransfer): set date failed..." << endl; dlog.warn() << "(fileTransfer): set date failed..." << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
......
...@@ -89,16 +89,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -89,16 +89,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: " if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -143,8 +146,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -143,8 +146,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
break; break;
} }
if( !activated ) if( !activated &amp;&amp; ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname ulog.crit() &lt;&lt; myname
&lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl; &lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl;
for( ;; ) for( ;; )
...@@ -162,15 +165,18 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -162,15 +165,18 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
} }
catch(SystemError&amp; err) catch(SystemError&amp; err)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl;
} }
msleep(askPause); msleep(askPause);
} }
...@@ -185,7 +191,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si ...@@ -185,7 +191,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( _sid == <xsl:value-of select="../../@name"/> ) if( _sid == <xsl:value-of select="../../@name"/> )
{ {
unideb[Debug::LEVEL2] &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl; if( ulog.is_level2() )
ulog.level2() &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val;
<xsl:call-template name="setdata"/> <xsl:call-template name="setdata"/>
return; return;
...@@ -217,16 +224,16 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -217,16 +224,16 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid=" ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
return 0; return 0;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
...@@ -292,8 +299,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -292,8 +299,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -328,8 +335,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -328,8 +335,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -344,8 +351,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -344,8 +351,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
......
...@@ -94,16 +94,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -94,16 +94,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: " if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -154,7 +157,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si ...@@ -154,7 +157,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( _sid == <xsl:value-of select="../../@name"/> ) if( _sid == <xsl:value-of select="../../@name"/> )
{ {
unideb[Debug::LEVEL2] &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl; if( ulog.is_level2() )
ulog.level2() &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val;
return; return;
} }
...@@ -176,8 +180,8 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -176,8 +180,8 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid=" ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
return 0; return 0;
...@@ -228,7 +232,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -228,7 +232,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -263,8 +268,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -263,8 +268,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -279,8 +284,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -279,8 +284,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
......
...@@ -88,16 +88,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -88,16 +88,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: " if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -113,7 +116,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si ...@@ -113,7 +116,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( _sid == <xsl:value-of select="@name"/> ) if( _sid == <xsl:value-of select="@name"/> )
{ {
unideb[Debug::LEVEL2] &lt;&lt; "(setState): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; _val &lt;&lt; endl; if( ulog.is_level2() )
ulog.level2() &lt;&lt; "(setState): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; _val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _val; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _val;
<xsl:call-template name="setdata"/> <xsl:call-template name="setdata"/>
return; return;
...@@ -184,14 +188,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -184,14 +188,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
} }
</xsl:for-each> </xsl:for-each>
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid=" ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
...@@ -210,8 +214,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -210,8 +214,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
break; break;
} }
if( !activated ) if( !activated &amp;&amp; ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname ulog.crit() &lt;&lt; myname
&lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl; &lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl;
for( ;; ) for( ;; )
...@@ -228,15 +232,18 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -228,15 +232,18 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
} }
catch(SystemError&amp; err) catch(SystemError&amp; err)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl;
} }
msleep(askPause); msleep(askPause);
} }
...@@ -268,8 +275,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -268,8 +275,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
...@@ -286,8 +293,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -286,8 +293,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
...@@ -305,8 +312,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -305,8 +312,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
......
...@@ -93,16 +93,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -93,16 +93,19 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: " if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -118,7 +121,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid ...@@ -118,7 +121,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( sid == <xsl:value-of select="@name"/> ) if( sid == <xsl:value-of select="@name"/> )
{ {
unideb[Debug::LEVEL2] &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; val &lt;&lt; endl; if( ulog.is_level2() )
ulog.level2() &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = val; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = val;
return; return;
} }
...@@ -174,7 +178,8 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -174,7 +178,8 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
</xsl:for-each> </xsl:for-each>
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid=" if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
return 0; return 0;
} }
...@@ -209,8 +214,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -209,8 +214,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -227,8 +232,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -227,8 +232,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -246,8 +251,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -246,8 +251,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -264,7 +269,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -264,7 +269,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setmsg): " &lt;&lt; ex &lt;&lt; endl; if( ulog.is_crit() )
ulog.crit() &lt;&lt; myname &lt;&lt; "(setmsg): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
......
...@@ -56,7 +56,7 @@ int main( int argc,char* argv[] ) ...@@ -56,7 +56,7 @@ int main( int argc,char* argv[] )
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log"); string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
unideb.logFile( logname.c_str() ); ulog.logFile( logname.c_str() );
// определяем ID объекта // определяем ID объекта
ObjectId ID(DefaultObjectId); ObjectId ID(DefaultObjectId);
......
...@@ -58,7 +58,7 @@ int main( int argc, const char** argv ) ...@@ -58,7 +58,7 @@ int main( int argc, const char** argv )
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log"); string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
unideb.logFile( logname.c_str() ); ulog.logFile( logname.c_str() );
<xsl:if test="not(normalize-space(//@OID))=''"> <xsl:if test="not(normalize-space(//@OID))=''">
<xsl:value-of select="$CLASSNAME"/> obj; <xsl:value-of select="$CLASSNAME"/> obj;
......
...@@ -14,14 +14,14 @@ int main( int argc, const char **argv ) ...@@ -14,14 +14,14 @@ int main( int argc, const char **argv )
string logfilename = conf->getArgParam("--logfile", "Skel.log"); string logfilename = conf->getArgParam("--logfile", "Skel.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
// dlog.logFile( logname.c_str() ); // dlog.logFile( logname.c_str() );
unideb.logFile( logname.c_str() ); ulog.logFile( logname.c_str() );
// conf->initDebug(dlog,"dlog"); // conf->initDebug(dlog,"dlog");
ObjectsActivator act; ObjectsActivator act;
xmlNode* cnode = conf->getNode("Skel"); xmlNode* cnode = conf->getNode("Skel");
if( cnode == NULL ) if( cnode == NULL )
{ {
dlog[Debug::CRIT] << "(Skel): not found <Skel> in conffile" << endl; dlog.crit() << "(Skel): not found <Skel> in conffile" << endl;
return 1; return 1;
} }
...@@ -31,8 +31,8 @@ int main( int argc, const char **argv ) ...@@ -31,8 +31,8 @@ int main( int argc, const char **argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog.ebug::ANY) << "\n\n\n";
unideb[Debug::ANY] << "(Skel::main): -------------- Skel START -------------------------\n\n"; ulog.ebug::ANY] << "(Skel::main): -------------- Skel START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog(Debug::ANY) << "\n\n\n";
dlog[Debug::ANY] << "(Skel::main): -------------- Skel START -------------------------\n\n"; dlog[Debug::ANY] << "(Skel::main): -------------- Skel START -------------------------\n\n";
act.run(false); act.run(false);
......
...@@ -353,6 +353,8 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -353,6 +353,8 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- refactoring <depends> mechanism - refactoring <depends> mechanism
- add iofront=[01,10] to IOBase - add iofront=[01,10] to IOBase
- remove deprecated interfaces (Storages,CycleStorage,TableStorage,TextIndex,..) - remove deprecated interfaces (Storages,CycleStorage,TableStorage,TextIndex,..)
- rename unideb --> ulog
- DebugStream refactoring (add new function)
* Tue Dec 10 2013 Pavel Vainerman <pv@altlinux.ru> 1.7-alt3 * Tue Dec 10 2013 Pavel Vainerman <pv@altlinux.ru> 1.7-alt3
- add RRDServer - add RRDServer
......
...@@ -147,32 +147,32 @@ void DBServer_MySQL::parse( UniSetTypes::ConfirmMessage* cem ) ...@@ -147,32 +147,32 @@ void DBServer_MySQL::parse( UniSetTypes::ConfirmMessage* cem )
<< " AND time='" << ui.timeToString(cem->time, ":") <<" '" << " AND time='" << ui.timeToString(cem->time, ":") <<" '"
<< " AND time_usec='" << cem->time_usec <<" '"; << " AND time_usec='" << cem->time_usec <<" '";
if( unideb.debugging(DBLEVEL) ) if( ulog.debugging(DBLEVEL) )
unideb[DBLEVEL] << myname << "(update_confirm): " << data.str() << endl; ulog[DBLEVEL] << myname << "(update_confirm): " << data.str() << endl;
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(update_confirm): db error: "<< db->error() << endl; ulog.crit() << myname << "(update_confirm): db error: "<< db->error() << endl;
db->freeResult(); db->freeResult();
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(update_confirm): " << ex << endl; ulog.crit() << myname << "(update_confirm): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(update_confirm): catch..." << endl; ulog.crit() << myname << "(update_confirm): catch..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool DBServer_MySQL::writeToBase( const string& query ) bool DBServer_MySQL::writeToBase( const string& query )
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(writeToBase): " << query << endl; ulog[DBLogInfoLevel] << myname << "(writeToBase): " << query << endl;
// cout << "DBServer_MySQL: " << query << endl; // cout << "DBServer_MySQL: " << query << endl;
if( !db || !connect_ok ) if( !db || !connect_ok )
{ {
...@@ -188,8 +188,8 @@ bool DBServer_MySQL::writeToBase( const string& query ) ...@@ -188,8 +188,8 @@ bool DBServer_MySQL::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(writeToBase): DB not connected! buffer(" << qbufSize ulog.crit() << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -231,9 +231,9 @@ void DBServer_MySQL::flushBuffer() ...@@ -231,9 +231,9 @@ void DBServer_MySQL::flushBuffer()
string err(db->error()); string err(db->error());
if( err.empty() ) if( err.empty() )
db->freeResult(); db->freeResult();
else if( unideb.debugging(Debug::CRIT) ) else if( ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(writeToBase): error: " << err << ulog.crit() << myname << "(writeToBase): error: " << err <<
" lost query: " << qbuf.front() << endl; " lost query: " << qbuf.front() << endl;
} }
...@@ -264,31 +264,33 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si ) ...@@ -264,31 +264,33 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
<< si->value << "," // value << si->value << "," // value
<< si->node << ")"; // node << si->node << ")"; // node
if( unideb.debugging(DBLEVEL) ) if( ulog.debugging(DBLEVEL) )
unideb[DBLEVEL] << myname << "(insert_main_history): " << data.str() << endl; ulog[DBLEVEL] << myname << "(insert_main_history): " << data.str() << endl;
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(insert) sensor msg error: "<< db->error() << endl; ulog.crit() << myname << "(insert) sensor msg error: "<< db->error() << endl;
db->freeResult(); db->freeResult();
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(insert_main_history): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(insert_main_history): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
unideb[Debug::CRIT] << myname << "(insert_main_history): catch ..." << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(insert_main_history): catch ..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_MySQL::init_dbserver() void DBServer_MySQL::init_dbserver()
{ {
DBServer::init_dbserver(); DBServer::init_dbserver();
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(init): ..." << endl; ulog[DBLogInfoLevel] << myname << "(init): ..." << endl;
if( connect_ok ) if( connect_ok )
{ {
...@@ -312,7 +314,7 @@ void DBServer_MySQL::init_dbserver() ...@@ -312,7 +314,7 @@ void DBServer_MySQL::init_dbserver()
UniXML::iterator it(node); UniXML::iterator it(node);
unideb[DBLogInfoLevel] << myname << "(init): init connection.." << endl; ulog[DBLogInfoLevel] << myname << "(init): init connection.." << endl;
string dbname(conf->getProp(node,"dbname")); string dbname(conf->getProp(node,"dbname"));
string dbnode(conf->getProp(node,"dbnode")); string dbnode(conf->getProp(node,"dbnode"));
string user(conf->getProp(node,"dbuser")); string user(conf->getProp(node,"dbuser"));
...@@ -335,8 +337,8 @@ void DBServer_MySQL::init_dbserver() ...@@ -335,8 +337,8 @@ void DBServer_MySQL::init_dbserver()
if( dbnode.empty() ) if( dbnode.empty() )
dbnode = "localhost"; dbnode = "localhost";
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(init): connect dbnode=" << dbnode ulog[DBLogInfoLevel] << myname << "(init): connect dbnode=" << dbnode
<< "\tdbname=" << dbname << "\tdbname=" << dbname
<< " pingTime=" << PingTime << " pingTime=" << PingTime
<< " ReconnectTime=" << ReconnectTime << endl; << " ReconnectTime=" << ReconnectTime << endl;
...@@ -344,8 +346,8 @@ void DBServer_MySQL::init_dbserver() ...@@ -344,8 +346,8 @@ void DBServer_MySQL::init_dbserver()
if( !db->connect(dbnode, user, password, dbname) ) if( !db->connect(dbnode, user, password, dbname) )
{ {
// ostringstream err; // ostringstream err;
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname ulog.crit() << myname
<< "(init): DB connection error: " << "(init): DB connection error: "
<< db->error() << endl; << db->error() << endl;
// throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) ); // throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) );
...@@ -353,8 +355,8 @@ void DBServer_MySQL::init_dbserver() ...@@ -353,8 +355,8 @@ void DBServer_MySQL::init_dbserver()
} }
else else
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(init): connect [OK]" << endl; ulog[DBLogInfoLevel] << myname << "(init): connect [OK]" << endl;
connect_ok = true; connect_ok = true;
askTimer(DBServer_MySQL::ReconnectTimer,0); askTimer(DBServer_MySQL::ReconnectTimer,0);
askTimer(DBServer_MySQL::PingTimer,PingTime); askTimer(DBServer_MySQL::PingTimer,PingTime);
...@@ -370,8 +372,8 @@ void DBServer_MySQL::createTables( DBInterface *db ) ...@@ -370,8 +372,8 @@ void DBServer_MySQL::createTables( DBInterface *db )
UniXML_iterator it( conf->getNode("Tables") ); UniXML_iterator it( conf->getNode("Tables") );
if(!it) if(!it)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << ": section <Tables> not found.."<< endl; ulog.crit() << myname << ": section <Tables> not found.."<< endl;
throw Exception(); throw Exception();
} }
...@@ -379,12 +381,12 @@ void DBServer_MySQL::createTables( DBInterface *db ) ...@@ -379,12 +381,12 @@ void DBServer_MySQL::createTables( DBInterface *db )
{ {
if( it.getName() != "comment" ) if( it.getName() != "comment" )
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl; ulog[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl;
ostringstream query; ostringstream query;
query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")"; query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")";
if( !db->query(query.str()) && unideb.debugging(Debug::CRIT) ) if( !db->query(query.str()) && ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(createTables): error: \t\t" << db->error() << endl; ulog.crit() << myname << "(createTables): error: \t\t" << db->error() << endl;
} }
} }
} }
...@@ -397,8 +399,8 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -397,8 +399,8 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
{ {
if( !db->ping() ) if( !db->ping() )
{ {
if( unideb.debugging(Debug::WARN) ) if( ulog.is_warn() )
unideb[Debug::WARN] << myname << "(timerInfo): DB lost connection.." << endl; ulog.warn() << myname << "(timerInfo): DB lost connection.." << endl;
connect_ok = false; connect_ok = false;
askTimer(DBServer_MySQL::PingTimer,0); askTimer(DBServer_MySQL::PingTimer,0);
askTimer(DBServer_MySQL::ReconnectTimer,ReconnectTime); askTimer(DBServer_MySQL::ReconnectTimer,ReconnectTime);
...@@ -406,16 +408,16 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -406,16 +408,16 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
else else
{ {
connect_ok = true; connect_ok = true;
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(timerInfo): DB ping ok" << endl; ulog[DBLogInfoLevel] << myname << "(timerInfo): DB ping ok" << endl;
} }
} }
break; break;
case DBServer_MySQL::ReconnectTimer: case DBServer_MySQL::ReconnectTimer:
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(timerInfo): reconnect timer" << endl; ulog[DBLogInfoLevel] << myname << "(timerInfo): reconnect timer" << endl;
if( db->isConnection() ) if( db->isConnection() )
{ {
if( db->ping() ) if( db->ping() )
...@@ -425,8 +427,8 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -425,8 +427,8 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
askTimer(DBServer_MySQL::PingTimer,PingTime); askTimer(DBServer_MySQL::PingTimer,PingTime);
} }
connect_ok = false; connect_ok = false;
if( unideb.debugging(Debug::WARN) ) if( ulog.is_warn() )
unideb[Debug::WARN] << myname << "(timerInfo): DB no connection.." << endl; ulog.warn() << myname << "(timerInfo): DB no connection.." << endl;
} }
else else
init_dbserver(); init_dbserver();
...@@ -434,8 +436,8 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -434,8 +436,8 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
break; break;
default: default:
if( unideb.debugging(Debug::WARN) ) if( ulog.is_warn() )
unideb[Debug::WARN] << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl; ulog.warn() << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl;
break; break;
} }
} }
......
...@@ -31,7 +31,7 @@ int main(int argc, char** argv) ...@@ -31,7 +31,7 @@ int main(int argc, char** argv)
{ {
if( ID != UniSetTypes::DefaultObjectId ) if( ID != UniSetTypes::DefaultObjectId )
{ {
unideb[Debug::WARN] << "(DBServer::main): переопределяем ID заданнй в " ulog.warn() << "(DBServer::main): переопределяем ID заданнй в "
<< conf->getConfFileName() << endl; << conf->getConfFileName() << endl;
} }
......
...@@ -143,31 +143,31 @@ void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem ) ...@@ -143,31 +143,31 @@ void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem )
<< " AND time='" << ui.timeToString(cem->time, ":") <<" '" << " AND time='" << ui.timeToString(cem->time, ":") <<" '"
<< " AND time_usec='" << cem->time_usec <<" '"; << " AND time_usec='" << cem->time_usec <<" '";
if( unideb.debugging(DBLEVEL) ) if( ulog.debugging(DBLEVEL) )
unideb[DBLEVEL] << myname << "(update_confirm): " << data.str() << endl; ulog[DBLEVEL] << myname << "(update_confirm): " << data.str() << endl;
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(update_confirm): db error: "<< db->error() << endl; ulog.crit() << myname << "(update_confirm): db error: "<< db->error() << endl;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(update_confirm): " << ex << endl; ulog.crit() << myname << "(update_confirm): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(update_confirm): catch..." << endl; ulog.crit() << myname << "(update_confirm): catch..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool DBServer_SQLite::writeToBase( const string& query ) bool DBServer_SQLite::writeToBase( const string& query )
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(writeToBase): " << query << endl; ulog[DBLogInfoLevel] << myname << "(writeToBase): " << query << endl;
// cout << "DBServer_SQLite: " << query << endl; // cout << "DBServer_SQLite: " << query << endl;
if( !db || !connect_ok ) if( !db || !connect_ok )
{ {
...@@ -183,8 +183,8 @@ bool DBServer_SQLite::writeToBase( const string& query ) ...@@ -183,8 +183,8 @@ bool DBServer_SQLite::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(writeToBase): DB not connected! buffer(" << qbufSize ulog.crit() << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -207,9 +207,9 @@ void DBServer_SQLite::flushBuffer() ...@@ -207,9 +207,9 @@ void DBServer_SQLite::flushBuffer()
// Сперва пробуем очистить всё что накопилось в очереди до этого... // Сперва пробуем очистить всё что накопилось в очереди до этого...
while( !qbuf.empty() ) while( !qbuf.empty() )
{ {
if( !db->insert(qbuf.front()) && unideb.debugging(Debug::CRIT) ) if( !db->insert(qbuf.front()) && ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(writeToBase): error: " << db->error() << ulog.crit() << myname << "(writeToBase): error: " << db->error() <<
" lost query: " << qbuf.front() << endl; " lost query: " << qbuf.front() << endl;
} }
qbuf.pop(); qbuf.pop();
...@@ -239,30 +239,30 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si ) ...@@ -239,30 +239,30 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
<< si->value << "," // value << si->value << "," // value
<< si->node << ")"; // node << si->node << ")"; // node
if( unideb.debugging(DBLEVEL) ) if( ulog.debugging(DBLEVEL) )
unideb[DBLEVEL] << myname << "(insert_main_history): " << data.str() << endl; ulog[DBLEVEL] << myname << "(insert_main_history): " << data.str() << endl;
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(insert) sensor msg error: "<< db->error() << endl; ulog.crit() << myname << "(insert) sensor msg error: "<< db->error() << endl;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(insert_main_history): " << ex << endl; ulog.crit() << myname << "(insert_main_history): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
unideb[Debug::CRIT] << myname << "(insert_main_history): catch ..." << endl; ulog.crit() << myname << "(insert_main_history): catch ..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_SQLite::init_dbserver() void DBServer_SQLite::init_dbserver()
{ {
DBServer::init_dbserver(); DBServer::init_dbserver();
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(init): ..." << endl; ulog[DBLogInfoLevel] << myname << "(init): ..." << endl;
if( connect_ok ) if( connect_ok )
{ {
...@@ -286,7 +286,7 @@ void DBServer_SQLite::init_dbserver() ...@@ -286,7 +286,7 @@ void DBServer_SQLite::init_dbserver()
UniXML::iterator it(node); UniXML::iterator it(node);
unideb[DBLogInfoLevel] << myname << "(init): init connection.." << endl; ulog[DBLogInfoLevel] << myname << "(init): init connection.." << endl;
string dbfile(conf->getProp(node,"dbfile")); string dbfile(conf->getProp(node,"dbfile"));
tblMap[UniSetTypes::Message::SensorInfo] = "main_history"; tblMap[UniSetTypes::Message::SensorInfo] = "main_history";
...@@ -303,16 +303,16 @@ void DBServer_SQLite::init_dbserver() ...@@ -303,16 +303,16 @@ void DBServer_SQLite::init_dbserver()
else else
lastRemove = false; lastRemove = false;
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(init): connect dbfile=" << dbfile ulog[DBLogInfoLevel] << myname << "(init): connect dbfile=" << dbfile
<< " pingTime=" << PingTime << " pingTime=" << PingTime
<< " ReconnectTime=" << ReconnectTime << endl; << " ReconnectTime=" << ReconnectTime << endl;
if( !db->connect(dbfile,false) ) if( !db->connect(dbfile,false) )
{ {
// ostringstream err; // ostringstream err;
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname ulog.crit() << myname
<< "(init): DB connection error: " << "(init): DB connection error: "
<< db->error() << endl; << db->error() << endl;
// throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) ); // throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) );
...@@ -320,8 +320,8 @@ void DBServer_SQLite::init_dbserver() ...@@ -320,8 +320,8 @@ void DBServer_SQLite::init_dbserver()
} }
else else
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(init): connect [OK]" << endl; ulog[DBLogInfoLevel] << myname << "(init): connect [OK]" << endl;
connect_ok = true; connect_ok = true;
askTimer(DBServer_SQLite::ReconnectTimer,0); askTimer(DBServer_SQLite::ReconnectTimer,0);
askTimer(DBServer_SQLite::PingTimer,PingTime); askTimer(DBServer_SQLite::PingTimer,PingTime);
...@@ -337,8 +337,8 @@ void DBServer_SQLite::createTables( SQLiteInterface *db ) ...@@ -337,8 +337,8 @@ void DBServer_SQLite::createTables( SQLiteInterface *db )
UniXML_iterator it( conf->getNode("Tables") ); UniXML_iterator it( conf->getNode("Tables") );
if(!it) if(!it)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << ": section <Tables> not found.."<< endl; ulog.crit() << myname << ": section <Tables> not found.."<< endl;
throw Exception(); throw Exception();
} }
...@@ -346,12 +346,12 @@ void DBServer_SQLite::createTables( SQLiteInterface *db ) ...@@ -346,12 +346,12 @@ void DBServer_SQLite::createTables( SQLiteInterface *db )
{ {
if( it.getName() != "comment" ) if( it.getName() != "comment" )
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl; ulog[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl;
ostringstream query; ostringstream query;
query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")"; query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")";
if( !db->query(query.str()) && unideb.debugging(Debug::CRIT) ) if( !db->query(query.str()) && ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(createTables): error: \t\t" << db->error() << endl; ulog.crit() << myname << "(createTables): error: \t\t" << db->error() << endl;
} }
} }
} }
...@@ -364,8 +364,8 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -364,8 +364,8 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
{ {
if( !db->ping() ) if( !db->ping() )
{ {
if( unideb.debugging(Debug::WARN) ) if( ulog.is_warn() )
unideb[Debug::WARN] << myname << "(timerInfo): DB lost connection.." << endl; ulog.warn() << myname << "(timerInfo): DB lost connection.." << endl;
connect_ok = false; connect_ok = false;
askTimer(DBServer_SQLite::PingTimer,0); askTimer(DBServer_SQLite::PingTimer,0);
askTimer(DBServer_SQLite::ReconnectTimer,ReconnectTime); askTimer(DBServer_SQLite::ReconnectTimer,ReconnectTime);
...@@ -373,16 +373,16 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -373,16 +373,16 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
else else
{ {
connect_ok = true; connect_ok = true;
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(timerInfo): DB ping ok" << endl; ulog[DBLogInfoLevel] << myname << "(timerInfo): DB ping ok" << endl;
} }
} }
break; break;
case DBServer_SQLite::ReconnectTimer: case DBServer_SQLite::ReconnectTimer:
{ {
if( unideb.debugging(DBLogInfoLevel) ) if( ulog.debugging(DBLogInfoLevel) )
unideb[DBLogInfoLevel] << myname << "(timerInfo): reconnect timer" << endl; ulog[DBLogInfoLevel] << myname << "(timerInfo): reconnect timer" << endl;
if( db->isConnection() ) if( db->isConnection() )
{ {
if( db->ping() ) if( db->ping() )
...@@ -392,8 +392,8 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -392,8 +392,8 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
askTimer(DBServer_SQLite::PingTimer,PingTime); askTimer(DBServer_SQLite::PingTimer,PingTime);
} }
connect_ok = false; connect_ok = false;
if( unideb.debugging(Debug::WARN) ) if( ulog.is_warn() )
unideb[Debug::WARN] << myname << "(timerInfo): DB no connection.." << endl; ulog.warn() << myname << "(timerInfo): DB no connection.." << endl;
} }
else else
init_dbserver(); init_dbserver();
...@@ -401,8 +401,8 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -401,8 +401,8 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
break; break;
default: default:
if( unideb.debugging(Debug::WARN) ) if( ulog.is_warn() )
unideb[Debug::WARN] << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl; ulog.warn() << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl;
break; break;
} }
} }
......
...@@ -31,7 +31,7 @@ int main(int argc, char** argv) ...@@ -31,7 +31,7 @@ int main(int argc, char** argv)
{ {
if( ID != UniSetTypes::DefaultObjectId ) if( ID != UniSetTypes::DefaultObjectId )
{ {
unideb[Debug::WARN] << "(DBServer::main): переопределяем ID заданнй в " ulog.warn() << "(DBServer::main): переопределяем ID заданнй в "
<< conf->getConfFileName() << endl; << conf->getConfFileName() << endl;
} }
......
...@@ -28,7 +28,7 @@ int main(int argc, const char **argv) ...@@ -28,7 +28,7 @@ int main(int argc, const char **argv)
string logfilename = conf->getArgParam("--io-logfile","iocontrol.log"); string logfilename = conf->getArgParam("--io-logfile","iocontrol.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
dlog.logFile( logname ); dlog.logFile( logname );
unideb.logFile( logname ); ulog.logFile( logname );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
string sID = conf->getArgParam("--smemory-id"); string sID = conf->getArgParam("--smemory-id");
...@@ -48,7 +48,7 @@ int main(int argc, const char **argv) ...@@ -48,7 +48,7 @@ int main(int argc, const char **argv)
IOControl* ic = IOControl::init_iocontrol(argc,argv,shmID); IOControl* ic = IOControl::init_iocontrol(argc,argv,shmID);
if( !ic ) if( !ic )
{ {
dlog[Debug::CRIT] << "(iocontrol): init не прошёл..." << endl; dlog.crit() << "(iocontrol): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -58,10 +58,10 @@ int main(int argc, const char **argv) ...@@ -58,10 +58,10 @@ int main(int argc, const char **argv)
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- IOControl START -------------------------\n\n"; ulog << "(main): -------------- IOControl START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- IOControl START -------------------------\n\n"; dlog << "(main): -------------- IOControl START -------------------------\n\n";
act.run(true); act.run(true);
msleep(500); msleep(500);
ic->execute(); ic->execute();
...@@ -69,15 +69,15 @@ int main(int argc, const char **argv) ...@@ -69,15 +69,15 @@ int main(int argc, const char **argv)
} }
catch(SystemError& err) catch(SystemError& err)
{ {
dlog[Debug::CRIT] << "(iocontrol): " << err << endl; dlog.crit() << "(iocontrol): " << err << endl;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog[Debug::CRIT] << "(iocontrol): " << ex << endl; dlog.crit() << "(iocontrol): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(iocontrol): catch(...)" << endl; dlog.crit() << "(iocontrol): catch(...)" << endl;
} }
return 1; return 1;
......
...@@ -35,15 +35,15 @@ void LProcessor::execute( const string& lfile ) ...@@ -35,15 +35,15 @@ void LProcessor::execute( const string& lfile )
} }
catch( LogicException& ex ) catch( LogicException& ex )
{ {
dlog[Debug::CRIT] << logname << "(execute): " << ex << endl; dlog.crit() << logname << "(execute): " << ex << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << logname << "(execute): " << ex << endl; dlog.crit() << logname << "(execute): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << logname << "(execute): catch...\n"; dlog.crit() << logname << "(execute): catch...\n";
} }
msleep(sleepTime); msleep(sleepTime);
} }
...@@ -67,7 +67,7 @@ void LProcessor::build( const string& lfile ) ...@@ -67,7 +67,7 @@ void LProcessor::build( const string& lfile )
UniSetTypes::ObjectId sid = conf->getSensorID(it->name); UniSetTypes::ObjectId sid = conf->getSensorID(it->name);
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
dlog[Debug::CRIT] << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ДАТЧИКА: " << it->name << endl; dlog.crit() << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ДАТЧИКА: " << it->name << endl;
continue; continue;
} }
...@@ -78,7 +78,7 @@ void LProcessor::build( const string& lfile ) ...@@ -78,7 +78,7 @@ void LProcessor::build( const string& lfile )
ei.iotype = conf->getIOType(sid); ei.iotype = conf->getIOType(sid);
if( ei.iotype == UniversalIO::UnknownIOType ) if( ei.iotype == UniversalIO::UnknownIOType )
{ {
dlog[Debug::CRIT] << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl; dlog.crit() << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl;
continue; continue;
} }
extInputs.push_front(ei); extInputs.push_front(ei);
...@@ -89,7 +89,7 @@ void LProcessor::build( const string& lfile ) ...@@ -89,7 +89,7 @@ void LProcessor::build( const string& lfile )
UniSetTypes::ObjectId sid = conf->getSensorID(it->name); UniSetTypes::ObjectId sid = conf->getSensorID(it->name);
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
dlog[Debug::CRIT] << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ВЫХОДА: " << it->name << endl; dlog.crit() << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ВЫХОДА: " << it->name << endl;
continue; continue;
} }
...@@ -99,7 +99,7 @@ void LProcessor::build( const string& lfile ) ...@@ -99,7 +99,7 @@ void LProcessor::build( const string& lfile )
ei.iotype = conf->getIOType(sid); ei.iotype = conf->getIOType(sid);
if( ei.iotype == UniversalIO::UnknownIOType ) if( ei.iotype == UniversalIO::UnknownIOType )
{ {
dlog[Debug::CRIT] << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl; dlog.crit() << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl;
continue; continue;
} }
...@@ -147,11 +147,11 @@ void LProcessor::setOuts() ...@@ -147,11 +147,11 @@ void LProcessor::setOuts()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(LProcessor::setOuts): " << ex << endl; dlog.crit() << "(LProcessor::setOuts): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(LProcessor::setOuts): catch...\n"; dlog.crit() << "(LProcessor::setOuts): catch...\n";
} }
} }
} }
......
...@@ -24,7 +24,8 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o ...@@ -24,7 +24,8 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
{ {
ostringstream err; ostringstream err;
err << myname << ": ID not found ('HeartBeat') for " << heart; err << myname << ": ID not found ('HeartBeat') for " << heart;
dlog[Debug::CRIT] << myname << "(init): " << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << myname << "(init): " << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -51,8 +52,8 @@ void PassiveLProcessor::step() ...@@ -51,8 +52,8 @@ void PassiveLProcessor::step()
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
dlog[Debug::CRIT] << myname if( dlog.is_crit() )
<< "(step): (hb) " << ex << std::endl; dlog.crit() << myname << "(step): (hb) " << ex << std::endl;
} }
if( sidHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() ) if( sidHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() )
...@@ -64,8 +65,8 @@ void PassiveLProcessor::step() ...@@ -64,8 +65,8 @@ void PassiveLProcessor::step()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog[Debug::CRIT] << myname if( dlog.is_crit() )
<< "(step): (hb) " << ex << std::endl; dlog.crit() << myname << "(step): (hb) " << ex << std::endl;
} }
} }
...@@ -85,7 +86,8 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -85,7 +86,8 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << myname << "(askSensors): " << ex << endl; if( dlog.is_crit() )
dlog.crit() << myname << "(askSensors): " << ex << endl;
throw SystemError(myname +"(askSensors): do not ask sensors" ); throw SystemError(myname +"(askSensors): do not ask sensors" );
} }
} }
...@@ -113,7 +115,8 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -113,7 +115,8 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
if( !shm->waitSMready(smReadyTimeout) ) if( !shm->waitSMready(smReadyTimeout) )
{ {
dlog[Debug::CRIT] << myname << "(ERR): SM not ready. Terminated... " << endl; if( dlog.is_crit() )
dlog.crit() << myname << "(ERR): SM not ready. Terminated... " << endl;
raise(SIGTERM); raise(SIGTERM);
return; return;
} }
...@@ -146,12 +149,12 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -146,12 +149,12 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
case SystemMessage::LogRotate: case SystemMessage::LogRotate:
{ {
// переоткрываем логи // переоткрываем логи
unideb << myname << "(sysCommand): logRotate" << std::endl; ulog << myname << "(sysCommand): logRotate" << std::endl;
string fname = unideb.getLogFile(); string fname (ulog.getLogFile() );
if( !fname.empty() ) if( !fname.empty() )
{ {
unideb.logFile(fname); ulog.logFile(fname);
unideb << myname << "(sysCommand): ***************** UNIDEB LOG ROTATE *****************" << std::endl; ulog << myname << "(sysCommand): ***************** UNIDEB LOG ROTATE *****************" << std::endl;
} }
dlog << myname << "(sysCommand): logRotate" << std::endl; dlog << myname << "(sysCommand): logRotate" << std::endl;
...@@ -199,11 +202,11 @@ void PassiveLProcessor::setOuts() ...@@ -199,11 +202,11 @@ void PassiveLProcessor::setOuts()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << myname << "(setOuts): " << ex << endl; dlog.crit() << myname << "(setOuts): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << myname << "(setOuts): catch...\n"; dlog.crit() << myname << "(setOuts): catch...\n";
} }
} }
} }
...@@ -218,11 +221,11 @@ void PassiveLProcessor::sigterm( int signo ) ...@@ -218,11 +221,11 @@ void PassiveLProcessor::sigterm( int signo )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << myname << "(sigterm): " << ex << endl; dlog.crit() << myname << "(sigterm): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << myname << "(sigterm): catch...\n"; dlog.crit() << myname << "(sigterm): catch...\n";
} }
} }
} }
...@@ -260,7 +263,7 @@ void PassiveLProcessor::processingMessage( UniSetTypes::VoidMessage* msg ) ...@@ -260,7 +263,7 @@ void PassiveLProcessor::processingMessage( UniSetTypes::VoidMessage* msg )
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(processingMessage): " << ex << endl; dlog.crit() << myname << "(processingMessage): " << ex << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -110,8 +110,8 @@ void Schema::extlink( const string& name, Element::ElementID childID, int numIn ...@@ -110,8 +110,8 @@ void Schema::extlink( const string& name, Element::ElementID childID, int numIn
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Element* Schema::manage( Element* el ) Element* Schema::manage( Element* el )
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "Schema: manage new element id=" << el->getId() dlog.info() << "Schema: manage new element id=" << el->getId()
<< " type=" << el->getType() << " type=" << el->getType()
<< " inputs=" << el->inCount() << endl; << " inputs=" << el->inCount() << endl;
......
...@@ -47,8 +47,8 @@ void TAND::setIn( int num, bool state ) ...@@ -47,8 +47,8 @@ void TAND::setIn( int num, bool state )
if( !brk ) if( !brk )
myout = true; myout = true;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << this << ": myout " << myout << endl; dlog.info() << this << ": myout " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
......
...@@ -30,8 +30,10 @@ void TDelay::setIn( int num, bool state ) ...@@ -30,8 +30,10 @@ void TDelay::setIn( int num, bool state )
{ {
pt.setTiming(0); // reset timer pt.setTiming(0); // reset timer
myout = false; myout = false;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": set " << myout << endl; if( dlog.is_info() )
dlog.info() << this << ": set " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
return; return;
...@@ -44,8 +46,10 @@ void TDelay::setIn( int num, bool state ) ...@@ -44,8 +46,10 @@ void TDelay::setIn( int num, bool state )
{ {
pt.setTiming(0); // reset timer pt.setTiming(0); // reset timer
myout = true; myout = true;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": set " << myout << endl; if( dlog.is_info() )
dlog.info() << this << ": set " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
return; return;
...@@ -54,8 +58,9 @@ void TDelay::setIn( int num, bool state ) ...@@ -54,8 +58,9 @@ void TDelay::setIn( int num, bool state )
// засекаем, если ещё не установлен таймер // засекаем, если ещё не установлен таймер
if( !myout && !prev ) // т.е. !myout && prev != myout if( !myout && !prev ) // т.е. !myout && prev != myout
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << this << ": set timer " << delay << " [msec]" << endl; dlog.info() << this << ": set timer " << delay << " [msec]" << endl;
pt.setTiming(delay); pt.setTiming(delay);
} }
} }
...@@ -66,8 +71,8 @@ void TDelay::tick() ...@@ -66,8 +71,8 @@ void TDelay::tick()
{ {
myout = true; myout = true;
pt.setTiming(0); // reset timer pt.setTiming(0); // reset timer
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << getType() << "(" << myid << "): TIMER!!!! myout=" << myout << endl; dlog.info() << getType() << "(" << myid << "): TIMER!!!! myout=" << myout << endl;
Element::setChildOut(); Element::setChildOut();
} }
} }
......
...@@ -22,8 +22,8 @@ void TNOT::setIn( int num, bool state ) ...@@ -22,8 +22,8 @@ void TNOT::setIn( int num, bool state )
bool prev = myout; bool prev = myout;
myout = !state; myout = !state;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << this << ": myout " << myout << endl; dlog.info() << this << ": myout " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
......
...@@ -60,8 +60,9 @@ void TOR::setIn( int num, bool state ) ...@@ -60,8 +60,9 @@ void TOR::setIn( int num, bool state )
if( !brk ) if( !brk )
myout = false; myout = false;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << this << ": myout " << myout << endl; dlog.info() << this << ": myout " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
} }
......
...@@ -23,13 +23,13 @@ int main(int argc, const char **argv) ...@@ -23,13 +23,13 @@ int main(int argc, const char **argv)
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
string schema = conf->getArgParam("--schema"); string schema = conf->getArgParam("--schema");
if( schema.empty() ) if( schema.empty() )
{ {
dlog[Debug::CRIT] << "schema-file not defined. Use --schema" << endl; dlog.crit() << "schema-file not defined. Use --schema" << endl;
return 1; return 1;
} }
......
...@@ -25,7 +25,7 @@ int main(int argc, const char **argv) ...@@ -25,7 +25,7 @@ int main(int argc, const char **argv)
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
string schema = conf->getArgParam("--schema"); string schema = conf->getArgParam("--schema");
...@@ -76,10 +76,10 @@ int main(int argc, const char **argv) ...@@ -76,10 +76,10 @@ int main(int argc, const char **argv)
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- IOControl START -------------------------\n\n"; ulog << "(main): -------------- IOControl START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- IOControl START -------------------------\n\n"; dlog << "(main): -------------- IOControl START -------------------------\n\n";
act.run(false); act.run(false);
return 0; return 0;
} }
......
...@@ -38,7 +38,7 @@ pollThread(0) ...@@ -38,7 +38,7 @@ pollThread(0)
prop_prefix = ""; prop_prefix = "";
} }
dlog[Debug::INFO] << myname << "(init): prop_prefix=" << prop_prefix << endl; dlog.info() << myname << "(init): prop_prefix=" << prop_prefix << endl;
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
...@@ -55,7 +55,7 @@ pollThread(0) ...@@ -55,7 +55,7 @@ pollThread(0)
force_disconnect = conf->getArgInt("--" + prefix + "-persistent-connection",it.getProp("persistent_connection")) ? false : true; force_disconnect = conf->getArgInt("--" + prefix + "-persistent-connection",it.getProp("persistent_connection")) ? false : true;
dlog[Debug::INFO] << myname << "(init): persisten-connection=" << (!force_disconnect) << endl; dlog.info() << myname << "(init): persisten-connection=" << (!force_disconnect) << endl;
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
...@@ -68,7 +68,7 @@ pollThread(0) ...@@ -68,7 +68,7 @@ pollThread(0)
pollThread = new ThreadCreator<MBTCPMaster>(this, &MBTCPMaster::poll_thread); pollThread = new ThreadCreator<MBTCPMaster>(this, &MBTCPMaster::poll_thread);
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
printMap(rmap); printMap(rmap);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -106,16 +106,16 @@ ModbusClient* MBTCPMaster::initMB( bool reopen ) ...@@ -106,16 +106,16 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
mbtcp->setAfterSendPause(aftersend_pause); mbtcp->setAfterSendPause(aftersend_pause);
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << "(init): ipaddr=" << iaddr << " port=" << port << endl; dlog.info() << myname << "(init): ipaddr=" << iaddr << " port=" << port << endl;
if( dlog.debugging(Debug::LEVEL9) ) if( dlog.debugging(Debug::LEVEL9) )
mbtcp->setLog(dlog); mbtcp->setLog(dlog);
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(init): " << ex << endl; dlog.warn() << "(init): " << ex << endl;
} }
catch(...) catch(...)
{ {
...@@ -183,7 +183,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv, ...@@ -183,7 +183,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
if( name.empty() ) if( name.empty() )
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.debugging(Debug::CRIT) )
dlog[Debug::CRIT] << "(MBTCPMaster): Не задан name'" << endl; dlog.crit() << "(MBTCPMaster): Не задан name'" << endl;
return 0; return 0;
} }
...@@ -191,14 +191,14 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv, ...@@ -191,14 +191,14 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
if( ID == UniSetTypes::DefaultObjectId ) if( ID == UniSetTypes::DefaultObjectId )
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.debugging(Debug::CRIT) )
dlog[Debug::CRIT] << "(MBTCPMaster): идентификатор '" << name dlog.crit() << "(MBTCPMaster): идентификатор '" << name
<< "' не найден в конф. файле!" << "' не найден в конф. файле!"
<< " в секции " << conf->getObjectsSection() << endl; << " в секции " << conf->getObjectsSection() << endl;
return 0; return 0;
} }
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(MBTCPMaster): name = " << name << "(" << ID << ")" << endl; dlog.info() << "(MBTCPMaster): name = " << name << "(" << ID << ")" << endl;
return new MBTCPMaster(ID,icID,ic,prefix); return new MBTCPMaster(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -40,7 +40,8 @@ checkThread(0) ...@@ -40,7 +40,8 @@ checkThread(0)
prop_prefix = ""; prop_prefix = "";
} }
dlog[Debug::INFO] << myname << "(init): prop_prefix=" << prop_prefix << endl; if( dlog.is_info() )
dlog.info() << myname << "(init): prop_prefix=" << prop_prefix << endl;
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
...@@ -52,7 +53,8 @@ checkThread(0) ...@@ -52,7 +53,8 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): not found <GateList>"; err << myname << "(init): not found <GateList>";
dlog[Debug::CRIT] << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -60,7 +62,8 @@ checkThread(0) ...@@ -60,7 +62,8 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): empty <GateList> ?!"; err << myname << "(init): empty <GateList> ?!";
dlog[Debug::CRIT] << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -72,7 +75,8 @@ checkThread(0) ...@@ -72,7 +75,8 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): ip='' in <GateList>"; err << myname << "(init): ip='' in <GateList>";
dlog[Debug::CRIT] << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -81,7 +85,8 @@ checkThread(0) ...@@ -81,7 +85,8 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): ERROR: port=''" << sinf.port << " for ip='" << sinf.ip << "' in <GateList>"; err << myname << "(init): ERROR: port=''" << sinf.port << " for ip='" << sinf.ip << "' in <GateList>";
dlog[Debug::CRIT] << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -92,7 +97,8 @@ checkThread(0) ...@@ -92,7 +97,8 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): ERROR: Unknown SensorID for '" << it1.getProp("respond") << "' in <GateList>"; err << myname << "(init): ERROR: Unknown SensorID for '" << it1.getProp("respond") << "' in <GateList>";
dlog[Debug::CRIT] << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
} }
...@@ -116,15 +122,16 @@ checkThread(0) ...@@ -116,15 +122,16 @@ checkThread(0)
mblist.push_back(sinf); mblist.push_back(sinf);
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << "(init): add slave channel " << sinf.myname << endl; dlog.info() << myname << "(init): add slave channel " << sinf.myname << endl;
} }
if( mblist.empty() ) if( mblist.empty() )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): empty <GateList>!"; err << myname << "(init): empty <GateList>!";
dlog[Debug::CRIT] << err.str() << endl; if( dlog.is_crit() )
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -148,8 +155,7 @@ checkThread(0) ...@@ -148,8 +155,7 @@ checkThread(0)
// неудачной попытки запросов по одному из каналов, то ПЕРЕОПРЕДЕЛЯЕМ reopen, на timeout.. // неудачной попытки запросов по одному из каналов, то ПЕРЕОПРЕДЕЛЯЕМ reopen, на timeout..
ptReopen.setTiming(ptTimeout.getInterval()); ptReopen.setTiming(ptTimeout.getInterval());
if( dlog.is_info() )
if( dlog.debugging(Debug::INFO) )
printMap(rmap); printMap(rmap);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -228,8 +234,8 @@ bool MBTCPMultiMaster::MBSlaveInfo::init() ...@@ -228,8 +234,8 @@ bool MBTCPMultiMaster::MBSlaveInfo::init()
{ {
// ost::Thread::setException(ost::Thread::throwException); // ost::Thread::setException(ost::Thread::throwException);
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << "(init): connect..." << endl; dlog.info() << myname << "(init): connect..." << endl;
mbtcp->connect(ip,port); mbtcp->connect(ip,port);
mbtcp->setForceDisconnect(force_disconnect); mbtcp->setForceDisconnect(force_disconnect);
...@@ -242,8 +248,8 @@ bool MBTCPMultiMaster::MBSlaveInfo::init() ...@@ -242,8 +248,8 @@ bool MBTCPMultiMaster::MBSlaveInfo::init()
mbtcp->setSleepPause(sleepPause_usec); mbtcp->setSleepPause(sleepPause_usec);
mbtcp->setAfterSendPause(aftersend_pause); mbtcp->setAfterSendPause(aftersend_pause);
if( mbtcp->isConnection() && dlog.debugging(Debug::INFO) ) if( mbtcp->isConnection() && dlog.is_info() )
dlog[Debug::INFO] << "(init): " << myname << " connect OK" << endl; dlog.info() << "(init): " << myname << " connect OK" << endl;
initOK = true; initOK = true;
} }
...@@ -251,13 +257,13 @@ bool MBTCPMultiMaster::MBSlaveInfo::init() ...@@ -251,13 +257,13 @@ bool MBTCPMultiMaster::MBSlaveInfo::init()
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(init): " << ex << endl; dlog.warn() << "(init): " << ex << endl;
} }
catch(...) catch(...)
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(init): " << myname << " catch ..." << endl; dlog.warn() << "(init): " << myname << " catch ..." << endl;
} }
initOK = false; initOK = false;
...@@ -312,8 +318,8 @@ void MBTCPMultiMaster::check_thread() ...@@ -312,8 +318,8 @@ void MBTCPMultiMaster::check_thread()
try try
{ {
bool r = it->check(); bool r = it->check();
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << "(check): " << it->myname << " " << ( r ? "OK" : "FAIL" ) << endl; dlog.info() << myname << "(check): " << it->myname << " " << ( r ? "OK" : "FAIL" ) << endl;
try try
{ {
...@@ -326,7 +332,7 @@ void MBTCPMultiMaster::check_thread() ...@@ -326,7 +332,7 @@ void MBTCPMultiMaster::check_thread()
catch( Exception& ex ) catch( Exception& ex )
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.debugging(Debug::CRIT) )
dlog[Debug::CRIT] << myname << "(check): (respond) " << ex << std::endl; dlog.crit() << myname << "(check): (respond) " << ex << std::endl;
} }
catch(...){} catch(...){}
...@@ -376,20 +382,20 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const* ...@@ -376,20 +382,20 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const*
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1");
if( name.empty() ) if( name.empty() )
{ {
dlog[Debug::CRIT] << "(MBTCPMultiMaster): Не задан name'" << endl; dlog.crit() << "(MBTCPMultiMaster): Не задан name'" << endl;
return 0; return 0;
} }
ObjectId ID = conf->getObjectID(name); ObjectId ID = conf->getObjectID(name);
if( ID == UniSetTypes::DefaultObjectId ) if( ID == UniSetTypes::DefaultObjectId )
{ {
dlog[Debug::CRIT] << "(MBTCPMultiMaster): идентификатор '" << name dlog.crit() << "(MBTCPMultiMaster): идентификатор '" << name
<< "' не найден в конф. файле!" << "' не найден в конф. файле!"
<< " в секции " << conf->getObjectsSection() << endl; << " в секции " << conf->getObjectsSection() << endl;
return 0; return 0;
} }
dlog[Debug::INFO] << "(MBTCPMultiMaster): name = " << name << "(" << ID << ")" << endl; dlog.info() << "(MBTCPMultiMaster): name = " << name << "(" << ID << ")" << endl;
return new MBTCPMultiMaster(ID,icID,ic,prefix); return new MBTCPMultiMaster(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -38,7 +38,7 @@ rs_pre_clean(false) ...@@ -38,7 +38,7 @@ rs_pre_clean(false)
prop_prefix = ""; prop_prefix = "";
} }
dlog[Debug::INFO] << myname << "(init): prop_prefix=" << prop_prefix << endl; dlog.info() << myname << "(init): prop_prefix=" << prop_prefix << endl;
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
...@@ -69,7 +69,7 @@ rs_pre_clean(false) ...@@ -69,7 +69,7 @@ rs_pre_clean(false)
initMB(false); initMB(false);
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
printMap(rmap); printMap(rmap);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -130,7 +130,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -130,7 +130,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
mbrtu->setSleepPause(sleepPause_usec); mbrtu->setSleepPause(sleepPause_usec);
mbrtu->setAfterSendPause(aftersend_pause); mbrtu->setAfterSendPause(aftersend_pause);
dlog[Debug::INFO] << myname << "(init): dev=" << devname << " speed=" << ComPort::getSpeed( mbrtu->getSpeed() ) << endl; dlog.info() << myname << "(init): dev=" << devname << " speed=" << ComPort::getSpeed( mbrtu->getSpeed() ) << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
...@@ -138,7 +138,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -138,7 +138,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
delete mbrtu; delete mbrtu;
mbrtu = 0; mbrtu = 0;
dlog[Debug::WARN] << myname << "(init): " << ex << endl; dlog.warn() << myname << "(init): " << ex << endl;
} }
catch(...) catch(...)
{ {
...@@ -146,7 +146,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -146,7 +146,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
delete mbrtu; delete mbrtu;
mbrtu = 0; mbrtu = 0;
dlog[Debug::INFO] << myname << "(init): catch...." << endl; dlog.info() << myname << "(init): catch...." << endl;
} }
mb = mbrtu; mb = mbrtu;
...@@ -244,7 +244,7 @@ void RTUExchange::poll() ...@@ -244,7 +244,7 @@ void RTUExchange::poll()
{ {
if( dlog.debugging(Debug::LEVEL3) ) if( dlog.debugging(Debug::LEVEL3) )
{ {
dlog[Debug::CRIT] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr) dlog.crit() << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " -> " << ex << endl; << " -> " << ex << endl;
} }
d->resp_real = false; d->resp_real = false;
...@@ -318,8 +318,8 @@ void RTUExchange::poll() ...@@ -318,8 +318,8 @@ void RTUExchange::poll()
if( allNotRespond && ptReopen.checkTime() ) if( allNotRespond && ptReopen.checkTime() )
{ {
uniset_mutex_lock l(pollMutex, 300); uniset_mutex_lock l(pollMutex, 300);
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl; dlog.warn() << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
mb = initMB(true); mb = initMB(true);
ptReopen.reset(); ptReopen.reset();
...@@ -347,7 +347,7 @@ RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, U ...@@ -347,7 +347,7 @@ RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, U
return 0; return 0;
} }
dlog[Debug::INFO] << "(rtuexchange): name = " << name << "(" << ID << ")" << endl; dlog.info() << "(rtuexchange): name = " << name << "(" << ID << ")" << endl;
return new RTUExchange(ID,icID,ic,prefix); return new RTUExchange(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -359,7 +359,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -359,7 +359,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
RTUDeviceMap::iterator d = m.find(a); RTUDeviceMap::iterator d = m.find(a);
if( d == m.end() ) if( d == m.end() )
{ {
dlog[Debug::WARN] << myname << "(initDeviceInfo): not found device for addr=" << ModbusRTU::addr2str(a) << endl; dlog.warn() << myname << "(initDeviceInfo): not found device for addr=" << ModbusRTU::addr2str(a) << endl;
return false; return false;
} }
...@@ -370,7 +370,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -370,7 +370,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
if( d->second->speed == ComPort::ComSpeed0 ) if( d->second->speed == ComPort::ComSpeed0 )
{ {
d->second->speed = defSpeed; d->second->speed = defSpeed;
dlog[Debug::CRIT] << myname << "(initDeviceInfo): Unknown speed=" << s << dlog.crit() << myname << "(initDeviceInfo): Unknown speed=" << s <<
" for addr=" << ModbusRTU::addr2str(a) << endl; " for addr=" << ModbusRTU::addr2str(a) << endl;
return false; return false;
} }
......
...@@ -36,7 +36,7 @@ int main( int argc, const char** argv ) ...@@ -36,7 +36,7 @@ int main( int argc, const char** argv )
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
...@@ -55,7 +55,7 @@ int main( int argc, const char** argv ) ...@@ -55,7 +55,7 @@ int main( int argc, const char** argv )
MBTCPMaster* mb = MBTCPMaster::init_mbmaster(argc,argv,shmID); MBTCPMaster* mb = MBTCPMaster::init_mbmaster(argc,argv,shmID);
if( !mb ) if( !mb )
{ {
dlog[Debug::CRIT] << "(mbmaster): init MBTCPMaster failed." << endl; dlog.crit() << "(mbmaster): init MBTCPMaster failed." << endl;
return 1; return 1;
} }
...@@ -65,21 +65,21 @@ int main( int argc, const char** argv ) ...@@ -65,21 +65,21 @@ int main( int argc, const char** argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- MBTCP Exchange START -------------------------\n\n"; ulog << "(main): -------------- MBTCP Exchange START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- MBTCP Exchange START -------------------------\n\n"; dlog << "(main): -------------- MBTCP Exchange START -------------------------\n\n";
act.run(false); act.run(false);
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
return 0; return 0;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(mbtcpmaster): " << ex << std::endl; dlog.crit() << "(mbtcpmaster): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(mbtcpmaster): catch ..." << std::endl; dlog.crit() << "(mbtcpmaster): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -36,7 +36,7 @@ int main( int argc, const char** argv ) ...@@ -36,7 +36,7 @@ int main( int argc, const char** argv )
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
...@@ -55,7 +55,7 @@ int main( int argc, const char** argv ) ...@@ -55,7 +55,7 @@ int main( int argc, const char** argv )
MBTCPMultiMaster* mb = MBTCPMultiMaster::init_mbmaster(argc,argv,shmID); MBTCPMultiMaster* mb = MBTCPMultiMaster::init_mbmaster(argc,argv,shmID);
if( !mb ) if( !mb )
{ {
dlog[Debug::CRIT] << "(mbmaster): init MBTCPMaster failed." << endl; dlog.crit() << "(mbmaster): init MBTCPMaster failed." << endl;
return 1; return 1;
} }
...@@ -65,21 +65,23 @@ int main( int argc, const char** argv ) ...@@ -65,21 +65,23 @@ int main( int argc, const char** argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- MBTCPMulti Exchange START -------------------------\n\n"; ulog << "(main): -------------- MBTCPMulti Exchange START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- MBTCPMulti Exchange START -------------------------\n\n"; dlog << "(main): -------------- MBTCPMulti Exchange START -------------------------\n\n";
act.run(false); act.run(false);
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
return 0; return 0;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(mbtcpmultimaster): " << ex << std::endl; dlog.crit() << "(mbtcpmultimaster): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(mbtcpmultimaster): catch ..." << std::endl; dlog.crit() << "(mbtcpmultimaster): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -34,7 +34,7 @@ int main( int argc, char** argv ) ...@@ -34,7 +34,7 @@ int main( int argc, char** argv )
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
...@@ -53,7 +53,7 @@ int main( int argc, char** argv ) ...@@ -53,7 +53,7 @@ int main( int argc, char** argv )
RTUExchange* rs = RTUExchange::init_rtuexchange(argc,argv,shmID,0,"rs"); RTUExchange* rs = RTUExchange::init_rtuexchange(argc,argv,shmID,0,"rs");
if( !rs ) if( !rs )
{ {
dlog[Debug::CRIT] << "(rtuexchange): init не прошёл..." << endl; dlog.crit() << "(rtuexchange): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -63,10 +63,10 @@ int main( int argc, char** argv ) ...@@ -63,10 +63,10 @@ int main( int argc, char** argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- RTU Exchange START -------------------------\n\n"; ulog << "(main): -------------- RTU Exchange START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- RTU Exchange START -------------------------\n\n"; dlog << "(main): -------------- RTU Exchange START -------------------------\n\n";
act.run(false); act.run(false);
...@@ -75,11 +75,11 @@ int main( int argc, char** argv ) ...@@ -75,11 +75,11 @@ int main( int argc, char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(rtuexchange): " << ex << std::endl; dlog.crit() << "(rtuexchange): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(rtuexchange): catch ..." << std::endl; dlog.crit() << "(rtuexchange): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -39,7 +39,7 @@ int main(int argc, const char **argv) ...@@ -39,7 +39,7 @@ int main(int argc, const char **argv)
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
...@@ -60,7 +60,7 @@ int main(int argc, const char **argv) ...@@ -60,7 +60,7 @@ int main(int argc, const char **argv)
MBSlave* s = MBSlave::init_mbslave(argc,argv,shmID); MBSlave* s = MBSlave::init_mbslave(argc,argv,shmID);
if( !s ) if( !s )
{ {
dlog[Debug::CRIT] << "(mbslave): init не прошёл..." << endl; dlog.crit() << "(mbslave): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -69,10 +69,10 @@ int main(int argc, const char **argv) ...@@ -69,10 +69,10 @@ int main(int argc, const char **argv)
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- MBSlave START -------------------------\n\n"; ulog << "(main): -------------- MBSlave START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- MBSlave START -------------------------\n\n"; dlog << "(main): -------------- MBSlave START -------------------------\n\n";
act.run(false); act.run(false);
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
...@@ -80,19 +80,19 @@ int main(int argc, const char **argv) ...@@ -80,19 +80,19 @@ int main(int argc, const char **argv)
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
dlog[Debug::CRIT] << "(mbslave): " << err << endl; dlog.crit() << "(mbslave): " << err << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(mbslave): " << ex << endl; dlog.crit() << "(mbslave): " << ex << endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
dlog[Debug::CRIT] << "(mbslave): " << e.what() << endl; dlog.crit() << "(mbslave): " << e.what() << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(mbslave): catch(...)" << endl; dlog.crit() << "(mbslave): catch(...)" << endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -25,7 +25,8 @@ prefix(prefix) ...@@ -25,7 +25,8 @@ prefix(prefix)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): empty rrd list..."; err << myname << "(init): empty rrd list...";
RRDServer::dlog[Debug::CRIT] << err.str() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str() << endl;
throw NameNotFound(err.str()); throw NameNotFound(err.str());
} }
...@@ -57,8 +58,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -57,8 +58,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
int lastup = it.getPIntProp("lastup",0); int lastup = it.getPIntProp("lastup",0);
bool overwrite = it.getPIntProp("overwrite",0); bool overwrite = it.getPIntProp("overwrite",0);
if( RRDServer::dlog.debugging(Debug::INFO) ) if( RRDServer::dlog.is_info() )
RRDServer::dlog[Debug::INFO] << myname << "(init): add rrd: file='" << fname RRDServer::dlog.info() << myname << "(init): add rrd: file='" << fname
<< " " << ff << "='" << fv << " " << ff << "='" << fv
<< "' create='" << cf << "'" << "' create='" << cf << "'"
<< " step=" << rrdstep << " step=" << rrdstep
...@@ -71,7 +72,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -71,7 +72,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): rrd='" << fname << "' Unknown RRA list"; err << myname << "(init): rrd='" << fname << "' Unknown RRA list";
RRDServer::dlog[Debug::CRIT] << err.str(); RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -82,7 +83,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -82,7 +83,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): rrd='" << fname << "' Unkown RRA item.. <item rra='...'"; err << myname << "(init): rrd='" << fname << "' Unkown RRA item.. <item rra='...'";
RRDServer::dlog[Debug::CRIT] << err.str(); if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -93,7 +95,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -93,7 +95,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Not found RRA items..."; err << myname << "(init): Not found RRA items...";
RRDServer::dlog[Debug::CRIT] << err.str() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -105,7 +108,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -105,7 +108,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Not found section <sensors>"; err << myname << "(init): Not found section <sensors>";
RRDServer::dlog[Debug::CRIT] << err.str(); if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -114,7 +118,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -114,7 +118,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): section <sensors> empty?!"; err << myname << "(init): section <sensors> empty?!";
RRDServer::dlog[Debug::CRIT] << err.str(); if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -133,7 +138,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -133,7 +138,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Unknown create parameters ('" << cf << "')"; err << myname << "(init): Unknown create parameters ('" << cf << "')";
RRDServer::dlog[Debug::CRIT] << err.str(); if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -147,7 +153,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -147,7 +153,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Unknown SensorID for '" << dsname << "'"; err << myname << "(init): Unknown SensorID for '" << dsname << "'";
RRDServer::dlog[Debug::CRIT] << err.str(); if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -159,7 +166,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -159,7 +166,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Not found RRD items..."; err << myname << "(init): Not found RRD items...";
RRDServer::dlog[Debug::CRIT] << err.str() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -179,8 +187,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -179,8 +187,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
// Собственно создаём RRD // Собственно создаём RRD
if( !overwrite && file_exist(fname) ) if( !overwrite && file_exist(fname) )
{ {
if( RRDServer::dlog.debugging(Debug::INFO) ) if( RRDServer::dlog.is_info() )
RRDServer::dlog[Debug::INFO] << myname << "(init): ignore create file='" << fname RRDServer::dlog.info() << myname << "(init): ignore create file='" << fname
<< "'. File exist... overwrite=0." << endl; << "'. File exist... overwrite=0." << endl;
} }
else else
...@@ -190,7 +198,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -190,7 +198,8 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Can`t create RRD ('" << fname << "'): err: " << string(rrd_get_error()); err << myname << "(init): Can`t create RRD ('" << fname << "'): err: " << string(rrd_get_error());
RRDServer::dlog[Debug::CRIT] << err.str() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
} }
...@@ -206,11 +215,11 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -206,11 +215,11 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
} }
/* catch( Exception& ex ) /* catch( Exception& ex )
{ {
RRDServer::dlog[Debug::CRIT] << myname << "(init) " << ex << std::endl; RRDServer::dlog.crit() << myname << "(init) " << ex << std::endl;
} }
catch( ... ) catch( ... )
{ {
RRDServer::dlog[Debug::CRIT] << myname << "(init): catch ..." << std::endl; RRDServer::dlog.crit() << myname << "(init): catch ..." << std::endl;
} }
*/ */
} }
...@@ -231,14 +240,14 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv, ...@@ -231,14 +240,14 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
string name = conf->getArgParam("--" + prefix + "-name","RRDServer"); string name = conf->getArgParam("--" + prefix + "-name","RRDServer");
if( name.empty() ) if( name.empty() )
{ {
UniSetExtensions::dlog[Debug::CRIT] << "(RRDServer): Unknown name. Usage: --" << prefix << "-name" << endl; UniSetExtensions::dlog.crit() << "(RRDServer): Unknown name. Usage: --" << prefix << "-name" << endl;
return 0; return 0;
} }
ObjectId ID = conf->getObjectID(name); ObjectId ID = conf->getObjectID(name);
if( ID == UniSetTypes::DefaultObjectId ) if( ID == UniSetTypes::DefaultObjectId )
{ {
UniSetExtensions::dlog[Debug::CRIT] << "(RRDServer): Not found ID for '" << name UniSetExtensions::dlog.crit() << "(RRDServer): Not found ID for '" << name
<< " in '" << conf->getObjectsSection() << "' section" << endl; << " in '" << conf->getObjectsSection() << "' section" << endl;
return 0; return 0;
} }
...@@ -247,11 +256,12 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv, ...@@ -247,11 +256,12 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
xmlNode* cnode = conf->getNode(confname); xmlNode* cnode = conf->getNode(confname);
if( !cnode ) if( !cnode )
{ {
UniSetExtensions::dlog[Debug::CRIT] << "(RRDServer): " << name << "(init): Not found <" + confname + ">" << endl; UniSetExtensions::dlog.crit() << "(RRDServer): " << name << "(init): Not found <" + confname + ">" << endl;
return 0; return 0;
} }
UniSetExtensions::dlog[Debug::INFO] << "(RRDServer): name = " << name << "(" << ID << ")" << endl; if( UniSetExtensions::dlog.is_info() )
UniSetExtensions::dlog.info() << "(RRDServer): name = " << name << "(" << ID << ")" << endl;
return new RRDServer(ID,cnode,icID,ic,prefix); return new RRDServer(ID,cnode,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -269,7 +279,8 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -269,7 +279,8 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd )
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
RRDServer::dlog[Debug::CRIT] << myname << "(askSensors): " << ex.what() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << myname << "(askSensors): " << ex.what() << endl;
} }
} }
} }
...@@ -288,7 +299,8 @@ void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm ) ...@@ -288,7 +299,8 @@ void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm )
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
RRDServer::dlog[Debug::CRIT] << myname << "(askTimer): " << ex.what() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << myname << "(askTimer): " << ex.what() << endl;
} }
} }
} }
...@@ -318,8 +330,8 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -318,8 +330,8 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm )
for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s ) for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s )
v << ":" << s->second.value; v << ":" << s->second.value;
if( RRDServer::dlog.debugging(Debug::INFO) ) if( RRDServer::dlog.is_info() )
RRDServer::dlog[Debug::INFO] << myname << "(update): '" << it->filename << "' " << v.str() << endl; RRDServer::dlog.info() << myname << "(update): '" << it->filename << "' " << v.str() << endl;
rrd_clear_error(); rrd_clear_error();
const char* argv = v.str().c_str(); const char* argv = v.str().c_str();
...@@ -327,7 +339,8 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -327,7 +339,8 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm )
{ {
ostringstream err; ostringstream err;
err << myname << "(update): Can`t update RRD ('" << it->filename << "'): err: " << string(rrd_get_error()); err << myname << "(update): Can`t update RRD ('" << it->filename << "'): err: " << string(rrd_get_error());
RRDServer::dlog[Debug::CRIT] << err.str() << endl; if( RRDServer::dlog.is_crit() )
RRDServer::dlog.crit() << err.str() << endl;
} }
break; break;
......
...@@ -35,7 +35,7 @@ int main( int argc, const char** argv ) ...@@ -35,7 +35,7 @@ int main( int argc, const char** argv )
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
...@@ -54,7 +54,7 @@ int main( int argc, const char** argv ) ...@@ -54,7 +54,7 @@ int main( int argc, const char** argv )
RRDServer* db = RRDServer::init_rrdstorage(argc,argv,shmID); RRDServer* db = RRDServer::init_rrdstorage(argc,argv,shmID);
if( !db ) if( !db )
{ {
dlog[Debug::CRIT] << "(rrdstorage): init не прошёл..." << endl; dlog.crit() << "(rrdstorage): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -64,20 +64,20 @@ int main( int argc, const char** argv ) ...@@ -64,20 +64,20 @@ int main( int argc, const char** argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- RRDServer START -------------------------\n\n"; ulog << "(main): -------------- RRDServer START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- RRDServer START -------------------------\n\n"; dlog << "(main): -------------- RRDServer START -------------------------\n\n";
act.run(false); act.run(false);
return 0; return 0;
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
dlog[Debug::CRIT] << "(rrdstorage): " << ex << std::endl; dlog.crit() << "(rrdstorage): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(rrdstorage): catch ..." << std::endl; dlog.crit() << "(rrdstorage): catch ..." << std::endl;
} }
return 1; return 1;
......
...@@ -42,7 +42,7 @@ prefix(prefix) ...@@ -42,7 +42,7 @@ prefix(prefix)
{ {
ostringstream err; ostringstream err;
err << myname << ": ID not found ('HeartBeat') for " << heart; err << myname << ": ID not found ('HeartBeat') for " << heart;
dlog[Debug::CRIT] << myname << "(init): " << err.str() << endl; dlog.crit() << myname << "(init): " << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -62,12 +62,12 @@ prefix(prefix) ...@@ -62,12 +62,12 @@ prefix(prefix)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): test_id unknown. 'TestMode_S' not found..."; err << myname << "(init): test_id unknown. 'TestMode_S' not found...";
dlog[Debug::CRIT] << myname << "(init): " << err.str() << endl; dlog.crit() << myname << "(init): " << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
} }
dlog[Debug::INFO] << myname << "(init): test_id=" << test_id << endl; dlog.info() << myname << "(init): test_id=" << test_id << endl;
} }
...@@ -90,7 +90,7 @@ void SMDBServer::waitSMReady() ...@@ -90,7 +90,7 @@ void SMDBServer::waitSMReady()
{ {
ostringstream err; ostringstream err;
err << myname << "(waitSMReady): Wait SharedMemory failed. [ " << ready_timeout << " msec ]"; err << myname << "(waitSMReady): Wait SharedMemory failed. [ " << ready_timeout << " msec ]";
dlog[Debug::CRIT] << err.str() << endl; dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
} }
...@@ -108,7 +108,7 @@ void SMDBServer::step() ...@@ -108,7 +108,7 @@ void SMDBServer::step()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(step): (hb) " << ex << std::endl; dlog.crit() << myname << "(step): (hb) " << ex << std::endl;
} }
} }
} }
...@@ -132,14 +132,14 @@ void SMDBServer::initDB( DBInterface *db ) ...@@ -132,14 +132,14 @@ void SMDBServer::initDB( DBInterface *db )
xmlNode* snode = conf->getXMLSensorsSection(); xmlNode* snode = conf->getXMLSensorsSection();
if(!snode) if(!snode)
{ {
dlog[Debug::CRIT] << myname << ": section <sensors> not found.." << endl; dlog.crit() << myname << ": section <sensors> not found.." << endl;
return; return;
} }
UniXML_iterator it(snode); UniXML_iterator it(snode);
if( !it.goChildren() ) if( !it.goChildren() )
{ {
dlog[Debug::CRIT] << myname << ": section <sensors> empty?!.." << endl; dlog.crit() << myname << ": section <sensors> empty?!.." << endl;
return; return;
} }
...@@ -156,18 +156,18 @@ void SMDBServer::initDB( DBInterface *db ) ...@@ -156,18 +156,18 @@ void SMDBServer::initDB( DBInterface *db )
if( !writeToBase("INSERT IGNORE INTO ObjectsMap(name,rep_name,id,msg)"+data.str()) ) if( !writeToBase("INSERT IGNORE INTO ObjectsMap(name,rep_name,id,msg)"+data.str()) )
{ {
dlog[Debug::CRIT] << myname << "(insert) ObjectsMap msg error: "<< db->error() << std::endl; dlog.crit() << myname << "(insert) ObjectsMap msg error: "<< db->error() << std::endl;
db->freeResult(); db->freeResult();
} }
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << myname << "(filling ObjectsMap): " << ex << std::endl; dlog.crit() << myname << "(filling ObjectsMap): " << ex << std::endl;
} }
catch( ... ) catch( ... )
{ {
dlog[Debug::CRIT] << myname << "(filling ObjectsMap): catch ..." << std::endl; dlog.crit() << myname << "(filling ObjectsMap): catch ..." << std::endl;
} }
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
...@@ -198,7 +198,7 @@ SMDBServer* SMDBServer::init_smdbserver( int argc, const char* const* argv, ...@@ -198,7 +198,7 @@ SMDBServer* SMDBServer::init_smdbserver( int argc, const char* const* argv,
return 0; return 0;
} }
dlog[Debug::INFO] << "(SMDBServer): name = " << name << "(" << ID << ")" << endl; dlog.info() << "(SMDBServer): name = " << name << "(" << ID << ")" << endl;
return new SMDBServer(ID,icID,ic,prefix); return new SMDBServer(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -35,7 +35,7 @@ int main( int argc, const char** argv ) ...@@ -35,7 +35,7 @@ int main( int argc, const char** argv )
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
dlog.logFile( logname.str() ); dlog.logFile( logname.str() );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
...@@ -54,7 +54,7 @@ int main( int argc, const char** argv ) ...@@ -54,7 +54,7 @@ int main( int argc, const char** argv )
SMDBServer* db = SMDBServer::init_smdbserver(argc,argv,shmID); SMDBServer* db = SMDBServer::init_smdbserver(argc,argv,shmID);
if( !db ) if( !db )
{ {
dlog[Debug::CRIT] << "(smdbserver): init не прошёл..." << endl; dlog.crit() << "(smdbserver): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -64,8 +64,8 @@ int main( int argc, const char** argv ) ...@@ -64,8 +64,8 @@ int main( int argc, const char** argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog.ebug::ANY) << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- SMDBServer START -------------------------\n\n"; ulog.ebug::ANY] << "(main): -------------- SMDBServer START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog(Debug::ANY) << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- SMDBServer START -------------------------\n\n"; dlog[Debug::ANY] << "(main): -------------- SMDBServer START -------------------------\n\n";
act.run(false); act.run(false);
...@@ -73,11 +73,11 @@ int main( int argc, const char** argv ) ...@@ -73,11 +73,11 @@ int main( int argc, const char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(smdbserver): " << ex << std::endl; dlog.crit() << "(smdbserver): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(smdbserver): catch ..." << std::endl; dlog.crit() << "(smdbserver): catch ..." << std::endl;
} }
return 1; return 1;
......
...@@ -25,7 +25,7 @@ int main(int argc, const char **argv) ...@@ -25,7 +25,7 @@ int main(int argc, const char **argv)
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log"); string logfilename = conf->getArgParam("--logfile", "smemory.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
unideb.logFile( logname ); ulog.logFile( logname );
dlog.logFile( logname ); dlog.logFile( logname );
SharedMemory* shm = SharedMemory::init_smemory(argc, argv); SharedMemory* shm = SharedMemory::init_smemory(argc, argv);
...@@ -44,19 +44,19 @@ int main(int argc, const char **argv) ...@@ -44,19 +44,19 @@ int main(int argc, const char **argv)
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
unideb[Debug::CRIT] << "(smemory): " << err << endl; ulog.crit() << "(smemory): " << err << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << "(smemory): " << ex << endl; ulog.crit() << "(smemory): " << ex << endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
unideb[Debug::CRIT] << "(smemory): " << e.what() << endl; ulog.crit() << "(smemory): " << e.what() << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] << "(smemory): catch(...)" << endl; ulog.crit() << "(smemory): catch(...)" << endl;
} }
return 1; return 1;
......
...@@ -52,7 +52,7 @@ int main( int argc, const char **argv ) ...@@ -52,7 +52,7 @@ int main( int argc, const char **argv )
string logfilename = conf->getArgParam("--logfile", "smemory-plus.log"); string logfilename = conf->getArgParam("--logfile", "smemory-plus.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
UniSetExtensions::dlog.logFile( logname ); UniSetExtensions::dlog.logFile( logname );
unideb.logFile( logname ); ulog.logFile( logname );
conf->initDebug(UniSetExtensions::dlog,"dlog"); conf->initDebug(UniSetExtensions::dlog,"dlog");
ObjectsActivator act; ObjectsActivator act;
...@@ -79,8 +79,8 @@ int main( int argc, const char **argv ) ...@@ -79,8 +79,8 @@ int main( int argc, const char **argv )
p << "io"; p << "io";
if( i > 0 ) p << i; if( i > 0 ) p << i;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(smemory-plus): add IOControl(" << p.str() << ")" << endl; dlog.info() << "(smemory-plus): add IOControl(" << p.str() << ")" << endl;
IOControl* ic = IOControl::init_iocontrol(argc,argv,shm->getId(),shm,p.str()); IOControl* ic = IOControl::init_iocontrol(argc,argv,shm->getId(),shm,p.str());
if( ic == NULL ) if( ic == NULL )
...@@ -108,8 +108,8 @@ int main( int argc, const char **argv ) ...@@ -108,8 +108,8 @@ int main( int argc, const char **argv )
p << "rtu"; p << "rtu";
if( i > 0 ) p << i; if( i > 0 ) p << i;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(smemory-plus): add RTUExchange(" << p.str() << ")" << endl; dlog.info() << "(smemory-plus): add RTUExchange(" << p.str() << ")" << endl;
RTUExchange* rtu = RTUExchange::init_rtuexchange(argc,argv,shm->getId(),shm,p.str()); RTUExchange* rtu = RTUExchange::init_rtuexchange(argc,argv,shm->getId(),shm,p.str());
if( rtu == NULL ) if( rtu == NULL )
...@@ -132,8 +132,8 @@ int main( int argc, const char **argv ) ...@@ -132,8 +132,8 @@ int main( int argc, const char **argv )
p << "mbs"; p << "mbs";
if( i > 0 ) p << i; if( i > 0 ) p << i;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(smemory-plus): add MBSlave(" << p.str() << ")" << endl; dlog.info() << "(smemory-plus): add MBSlave(" << p.str() << ")" << endl;
MBSlave* mbs = MBSlave::init_mbslave(argc,argv,shm->getId(),shm,p.str()); MBSlave* mbs = MBSlave::init_mbslave(argc,argv,shm->getId(),shm,p.str());
if( mbs == NULL ) if( mbs == NULL )
...@@ -158,8 +158,8 @@ int main( int argc, const char **argv ) ...@@ -158,8 +158,8 @@ int main( int argc, const char **argv )
p << "mbtcp"; p << "mbtcp";
if( i > 0 ) p << i; if( i > 0 ) p << i;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(smemory-plus): add MBTCPMaster(" << p.str() << ")" << endl; dlog.info() << "(smemory-plus): add MBTCPMaster(" << p.str() << ")" << endl;
MBTCPMaster* mbm1 = MBTCPMaster::init_mbmaster(argc,argv,shm->getId(),shm,p.str()); MBTCPMaster* mbm1 = MBTCPMaster::init_mbmaster(argc,argv,shm->getId(),shm,p.str());
if( mbm1 == NULL ) if( mbm1 == NULL )
...@@ -176,8 +176,8 @@ int main( int argc, const char **argv ) ...@@ -176,8 +176,8 @@ int main( int argc, const char **argv )
if( unet == NULL ) if( unet == NULL )
return 1; return 1;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(smemory-plus): add UNetExchnage.." << endl; dlog.info() << "(smemory-plus): add UNetExchnage.." << endl;
act.addObject(static_cast<class UniSetObject*>(unet)); act.addObject(static_cast<class UniSetObject*>(unet));
} }
...@@ -198,15 +198,15 @@ int main( int argc, const char **argv ) ...@@ -198,15 +198,15 @@ int main( int argc, const char **argv )
} }
catch(Exception& ex) catch(Exception& ex)
{ {
unideb[Debug::CRIT] << "(smemory-plus): " << ex << endl; ulog.crit() << "(smemory-plus): " << ex << endl;
} }
catch( CORBA::SystemException& ex ) catch( CORBA::SystemException& ex )
{ {
unideb[Debug::CRIT] << "(smemory-plus): " << ex.NP_minorString() << endl; ulog.crit() << "(smemory-plus): " << ex.NP_minorString() << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] << "(smemory-plus): catch(...)" << endl; ulog.crit() << "(smemory-plus): catch(...)" << endl;
} }
on_sigchild(SIGTERM); on_sigchild(SIGTERM);
......
...@@ -64,14 +64,14 @@ a_cache_init_ok(false) ...@@ -64,14 +64,14 @@ a_cache_init_ok(false)
{ {
ostringstream s; ostringstream s;
s << myname << ": " << e.what(); s << myname << ": " << e.what();
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
catch( ... ) catch( ... )
{ {
ostringstream s; ostringstream s;
s << myname << ": catch..."; s << myname << ": catch...";
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
...@@ -177,11 +177,11 @@ void UNetReceiver::update() ...@@ -177,11 +177,11 @@ void UNetReceiver::update()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(update): " << ex << std::endl; dlog.crit() << myname << "(update): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << myname << "(update): catch ..." << std::endl; dlog.crit() << myname << "(update): catch ..." << std::endl;
} }
if( sidRespond!=DefaultObjectId ) if( sidRespond!=DefaultObjectId )
...@@ -193,7 +193,7 @@ void UNetReceiver::update() ...@@ -193,7 +193,7 @@ void UNetReceiver::update()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(step): (respond) " << ex << std::endl; dlog.crit() << myname << "(step): (respond) " << ex << std::endl;
} }
} }
...@@ -205,7 +205,7 @@ void UNetReceiver::update() ...@@ -205,7 +205,7 @@ void UNetReceiver::update()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(step): (lostPackets) " << ex << std::endl; dlog.crit() << myname << "(step): (lostPackets) " << ex << std::endl;
} }
} }
...@@ -286,7 +286,7 @@ void UNetReceiver::real_update() ...@@ -286,7 +286,7 @@ void UNetReceiver::real_update()
ItemInfo& ii(d_icache[i]); ItemInfo& ii(d_icache[i]);
if( ii.id != id ) if( ii.id != id )
{ {
dlog[Debug::WARN] << myname << "(update): reinit cache for sid=" << id << endl; dlog.warn() << myname << "(update): reinit cache for sid=" << id << endl;
ii.id = id; ii.id = id;
shm->initIterator(ii.ioit); shm->initIterator(ii.ioit);
} }
...@@ -302,11 +302,11 @@ void UNetReceiver::real_update() ...@@ -302,11 +302,11 @@ void UNetReceiver::real_update()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(update): " << ex << std::endl; dlog.crit() << myname << "(update): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << myname << "(update): catch ..." << std::endl; dlog.crit() << myname << "(update): catch ..." << std::endl;
} }
} }
...@@ -319,7 +319,7 @@ void UNetReceiver::real_update() ...@@ -319,7 +319,7 @@ void UNetReceiver::real_update()
ItemInfo& ii(a_icache[i]); ItemInfo& ii(a_icache[i]);
if( ii.id != d.id ) if( ii.id != d.id )
{ {
dlog[Debug::WARN] << myname << "(update): reinit cache for sid=" << d.id << endl; dlog.warn() << myname << "(update): reinit cache for sid=" << d.id << endl;
ii.id = d.id; ii.id = d.id;
shm->initIterator(ii.ioit); shm->initIterator(ii.ioit);
} }
...@@ -335,11 +335,11 @@ void UNetReceiver::real_update() ...@@ -335,11 +335,11 @@ void UNetReceiver::real_update()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog[Debug::CRIT] << myname << "(update): " << ex << std::endl; dlog.crit() << myname << "(update): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << myname << "(update): catch ..." << std::endl; dlog.crit() << myname << "(update): catch ..." << std::endl;
} }
} }
} }
...@@ -356,8 +356,8 @@ void UNetReceiver::stop() ...@@ -356,8 +356,8 @@ void UNetReceiver::stop()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::receive() void UNetReceiver::receive()
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << ": ******************* receive start" << endl; dlog.info() << myname << ": ******************* receive start" << endl;
{ {
uniset_rwmutex_wrlock l(tmMutex); uniset_rwmutex_wrlock l(tmMutex);
...@@ -377,18 +377,18 @@ void UNetReceiver::receive() ...@@ -377,18 +377,18 @@ void UNetReceiver::receive()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << myname << "(receive): " << ex << std::endl; dlog.warn() << myname << "(receive): " << ex << std::endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << myname << "(receive): " << e.what()<< std::endl; dlog.warn() << myname << "(receive): " << e.what()<< std::endl;
} }
catch(...) catch(...)
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << myname << "(receive): catch ..." << std::endl; dlog.warn() << myname << "(receive): catch ..." << std::endl;
} }
// делаем через промежуточную переменную // делаем через промежуточную переменную
...@@ -410,8 +410,8 @@ void UNetReceiver::receive() ...@@ -410,8 +410,8 @@ void UNetReceiver::receive()
msleep(recvpause); msleep(recvpause);
} }
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << ": ************* receive FINISH **********" << endl; dlog.info() << myname << ": ************* receive FINISH **********" << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UNetReceiver::recv() bool UNetReceiver::recv()
...@@ -424,7 +424,7 @@ bool UNetReceiver::recv() ...@@ -424,7 +424,7 @@ bool UNetReceiver::recv()
size_t sz = UniSetUDP::UDPMessage::getMessage(pack,r_buf); size_t sz = UniSetUDP::UDPMessage::getMessage(pack,r_buf);
if( sz == 0 ) if( sz == 0 )
{ {
dlog[Debug::CRIT] << myname << "(receive): FAILED RECEIVE DATA ret=" << ret << endl; dlog.crit() << myname << "(receive): FAILED RECEIVE DATA ret=" << ret << endl;
return false; return false;
} }
...@@ -439,7 +439,7 @@ bool UNetReceiver::recv() ...@@ -439,7 +439,7 @@ bool UNetReceiver::recv()
// Обычно "кольцевой". Т.е. если не успели обработать и "вынуть" из буфера информацию.. он будет переписан новыми данными // Обычно "кольцевой". Т.е. если не успели обработать и "вынуть" из буфера информацию.. он будет переписан новыми данными
if( waitClean ) if( waitClean )
{ {
dlog[Debug::CRIT] << myname << "(receive): reset qtmp.." << endl; dlog.crit() << myname << "(receive): reset qtmp.." << endl;
while( !qtmp.empty() ) while( !qtmp.empty() )
qtmp.pop(); qtmp.pop();
} }
...@@ -510,7 +510,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -510,7 +510,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
if( !force && pack.dcount == d_icache.size() ) if( !force && pack.dcount == d_icache.size() )
return; return;
dlog[Debug::INFO] << myname << ": init icache.." << endl; dlog.info() << myname << ": init icache.." << endl;
d_cache_init_ok = true; d_cache_init_ok = true;
d_icache.resize(pack.dcount); d_icache.resize(pack.dcount);
...@@ -532,7 +532,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -532,7 +532,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
if( !force && pack.acount == a_icache.size() ) if( !force && pack.acount == a_icache.size() )
return; return;
dlog[Debug::INFO] << myname << ": init icache.." << endl; dlog.info() << myname << ": init icache.." << endl;
a_cache_init_ok = true; a_cache_init_ok = true;
a_icache.resize(pack.acount); a_icache.resize(pack.acount);
......
...@@ -31,11 +31,11 @@ s_thr(0) ...@@ -31,11 +31,11 @@ s_thr(0)
// определяем фильтр // определяем фильтр
// s_field = conf->getArgParam("--udp-filter-field"); // s_field = conf->getArgParam("--udp-filter-field");
// s_fvalue = conf->getArgParam("--udp-filter-value"); // s_fvalue = conf->getArgParam("--udp-filter-value");
dlog[Debug::INFO] << myname << "(init): read filter-field='" << s_field dlog.info() << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(UNetSender): UDP set to " << s_host << ":" << port << endl; dlog.info() << "(UNetSender): UDP set to " << s_host << ":" << port << endl;
ost::Thread::setException(ost::Thread::throwException); ost::Thread::setException(ost::Thread::throwException);
try try
...@@ -47,14 +47,14 @@ s_thr(0) ...@@ -47,14 +47,14 @@ s_thr(0)
{ {
ostringstream s; ostringstream s;
s << myname << ": " << e.what(); s << myname << ": " << e.what();
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
catch( ... ) catch( ... )
{ {
ostringstream s; ostringstream s;
s << myname << ": catch..."; s << myname << ": catch...";
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
...@@ -65,7 +65,7 @@ s_thr(0) ...@@ -65,7 +65,7 @@ s_thr(0)
{ {
readConfiguration(); readConfiguration();
dlist.resize(maxItem); dlist.resize(maxItem);
dlog[Debug::INFO] << myname << "(init): dlist size = " << dlist.size() << endl; dlog.info() << myname << "(init): dlist size = " << dlist.size() << endl;
} }
else else
ic->addReadItem( sigc::mem_fun(this,&UNetSender::readItem) ); ic->addReadItem( sigc::mem_fun(this,&UNetSender::readItem) );
...@@ -130,7 +130,7 @@ void UNetSender::updateItem( DMap::iterator& it, long value ) ...@@ -130,7 +130,7 @@ void UNetSender::updateItem( DMap::iterator& it, long value )
void UNetSender::send() void UNetSender::send()
{ {
dlist.resize(maxItem); dlist.resize(maxItem);
dlog[Debug::INFO] << myname << "(send): dlist size = " << dlist.size() << endl; dlog.info() << myname << "(send): dlist size = " << dlist.size() << endl;
/* /*
ost::IPV4Broadcast h = s_host.c_str(); ost::IPV4Broadcast h = s_host.c_str();
try try
...@@ -141,7 +141,7 @@ void UNetSender::send() ...@@ -141,7 +141,7 @@ void UNetSender::send()
{ {
ostringstream s; ostringstream s;
s << e.getString() << ": " << e.getSystemErrorString(); s << e.getString() << ": " << e.getSystemErrorString();
dlog[Debug::CRIT] << myname << "(poll): " << s.str() << endl; dlog.crit() << myname << "(poll): " << s.str() << endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
*/ */
...@@ -156,25 +156,25 @@ void UNetSender::send() ...@@ -156,25 +156,25 @@ void UNetSender::send()
} }
catch( ost::SockException& e ) catch( ost::SockException& e )
{ {
dlog[Debug::WARN] << myname << "(send): " << e.getString() << endl; dlog.warn() << myname << "(send): " << e.getString() << endl;
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog[Debug::WARN] << myname << "(send): " << ex << std::endl; dlog.warn() << myname << "(send): " << ex << std::endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
dlog[Debug::WARN] << myname << "(send): " << e.what() << std::endl; dlog.warn() << myname << "(send): " << e.what() << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::WARN] << myname << "(send): catch ..." << std::endl; dlog.warn() << myname << "(send): catch ..." << std::endl;
} }
msleep(sendpause); msleep(sendpause);
} }
dlog[Debug::INFO] << "************* execute FINISH **********" << endl; dlog.info() << "************* execute FINISH **********" << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::real_send() void UNetSender::real_send()
...@@ -191,7 +191,7 @@ void UNetSender::real_send() ...@@ -191,7 +191,7 @@ void UNetSender::real_send()
mypack.transport_msg(s_msg); mypack.transport_msg(s_msg);
size_t ret = udp->send( (char*)s_msg.data, s_msg.len ); size_t ret = udp->send( (char*)s_msg.data, s_msg.len );
if( ret < s_msg.len ) if( ret < s_msg.len )
dlog[Debug::CRIT] << myname << "(real_send): FAILED ret=" << ret << " < sizeof=" << s_msg.len << endl; dlog.crit() << myname << "(real_send): FAILED ret=" << ret << " < sizeof=" << s_msg.len << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::stop() void UNetSender::stop()
...@@ -259,7 +259,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -259,7 +259,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
if( dlog ) if( dlog )
dlog[Debug::CRIT] << myname << "(readItem): ID not found for " dlog.crit() << myname << "(readItem): ID not found for "
<< sname << endl; << sname << endl;
return false; return false;
} }
...@@ -269,7 +269,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -269,7 +269,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
if( p.iotype == UniversalIO::UnknownIOType ) if( p.iotype == UniversalIO::UnknownIOType )
{ {
dlog[Debug::CRIT] << myname << "(readItem): Unknown iotype for sid=" << sid << endl; dlog.crit() << myname << "(readItem): Unknown iotype for sid=" << sid << endl;
return false; return false;
} }
...@@ -280,7 +280,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -280,7 +280,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
p.pack_ind = mypack.addDData(sid,0); p.pack_ind = mypack.addDData(sid,0);
if ( p.pack_ind >= UniSetUDP::MaxDCount ) if ( p.pack_ind >= UniSetUDP::MaxDCount )
{ {
dlog[Debug::CRIT] << myname dlog.crit() << myname
<< "(readItem): OVERFLOW! MAX UDP DIGITAL DATA LIMIT! max=" << "(readItem): OVERFLOW! MAX UDP DIGITAL DATA LIMIT! max="
<< UniSetUDP::MaxDCount << endl; << UniSetUDP::MaxDCount << endl;
...@@ -293,7 +293,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -293,7 +293,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
p.pack_ind = mypack.addAData(sid,0); p.pack_ind = mypack.addAData(sid,0);
if ( p.pack_ind >= UniSetUDP::MaxACount ) if ( p.pack_ind >= UniSetUDP::MaxACount )
{ {
dlog[Debug::CRIT] << myname dlog.crit() << myname
<< "(readItem): OVERFLOW! MAX UDP ANALOG DATA LIMIT! max=" << "(readItem): OVERFLOW! MAX UDP ANALOG DATA LIMIT! max="
<< UniSetUDP::MaxACount << endl; << UniSetUDP::MaxACount << endl;
raise(SIGTERM); raise(SIGTERM);
...@@ -307,8 +307,8 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -307,8 +307,8 @@ bool UNetSender::initItem( UniXML_iterator& it )
dlist[maxItem] = p; dlist[maxItem] = p;
maxItem++; maxItem++;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << "(initItem): add " << p << endl; dlog.info() << myname << "(initItem): add " << p << endl;
return true; return true;
} }
......
...@@ -32,7 +32,7 @@ int main( int argc, const char** argv ) ...@@ -32,7 +32,7 @@ int main( int argc, const char** argv )
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); ulog.logFile( logname.str() );
UniSetExtensions::dlog.logFile( logname.str() ); UniSetExtensions::dlog.logFile( logname.str() );
conf->initDebug(UniSetExtensions::dlog,"dlog"); conf->initDebug(UniSetExtensions::dlog,"dlog");
...@@ -52,7 +52,7 @@ int main( int argc, const char** argv ) ...@@ -52,7 +52,7 @@ int main( int argc, const char** argv )
UNetExchange* unet = UNetExchange::init_unetexchange(argc,argv,shmID); UNetExchange* unet = UNetExchange::init_unetexchange(argc,argv,shmID);
if( !unet ) if( !unet )
{ {
dlog[Debug::CRIT] << "(unetexchange): init failed.." << endl; dlog.crit() << "(unetexchange): init failed.." << endl;
return 1; return 1;
} }
...@@ -62,21 +62,21 @@ int main( int argc, const char** argv ) ...@@ -62,21 +62,21 @@ int main( int argc, const char** argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n"; ulog << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- UDPRecevier START -------------------------\n\n"; ulog << "(main): -------------- UDPRecevier START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- UDPReceiver START -------------------------\n\n"; dlog << "(main): -------------- UDPReceiver START -------------------------\n\n";
act.run(false); act.run(false);
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(unetexchange): " << ex << std::endl; dlog.crit() << "(unetexchange): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(unetexchange): catch ..." << std::endl; dlog.crit() << "(unetexchange): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -36,18 +36,18 @@ smReadyTimeout(15000) ...@@ -36,18 +36,18 @@ smReadyTimeout(15000)
s_field = conf->getArgParam("--" + prefix + "-filter-field"); s_field = conf->getArgParam("--" + prefix + "-filter-field");
s_fvalue = conf->getArgParam("--" + prefix + "-filter-value"); s_fvalue = conf->getArgParam("--" + prefix + "-filter-value");
dlog[Debug::INFO] << myname << "(init): read fileter-field='" << s_field dlog.info() << myname << "(init): read fileter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
polltime = conf->getArgInt("--" + prefix + "-polltime",it.getProp("polltime")); polltime = conf->getArgInt("--" + prefix + "-polltime",it.getProp("polltime"));
if( polltime <= 0 ) if( polltime <= 0 )
polltime = 200; polltime = 200;
dlog[Debug::INFO] << myname << "(init): polltime=" << polltime << endl; dlog.info() << myname << "(init): polltime=" << polltime << endl;
int updatetime = conf->getArgInt("--" + prefix + "-updatetime",it.getProp("updatetime")); int updatetime = conf->getArgInt("--" + prefix + "-updatetime",it.getProp("updatetime"));
if( updatetime <= 0 ) if( updatetime <= 0 )
updatetime = 200; updatetime = 200;
dlog[Debug::INFO] << myname << "(init): updatetime=" << polltime << endl; dlog.info() << myname << "(init): updatetime=" << polltime << endl;
ptUpdate.setTiming(updatetime); ptUpdate.setTiming(updatetime);
...@@ -57,7 +57,7 @@ smReadyTimeout(15000) ...@@ -57,7 +57,7 @@ smReadyTimeout(15000)
else if( smReadyTimeout < 0 ) else if( smReadyTimeout < 0 )
smReadyTimeout = UniSetTimer::WaitUpTime; smReadyTimeout = UniSetTimer::WaitUpTime;
dlog[Debug::INFO] << myname << "(init): smReadyTimeout=" << smReadyTimeout << endl; dlog.info() << myname << "(init): smReadyTimeout=" << smReadyTimeout << endl;
if( it.goChildren() ) if( it.goChildren() )
{ {
...@@ -97,7 +97,7 @@ smReadyTimeout(15000) ...@@ -97,7 +97,7 @@ smReadyTimeout(15000)
ni.node = node; ni.node = node;
ni.sidConnection = conf->getSensorID(it.getProp("sid_connection")); ni.sidConnection = conf->getSensorID(it.getProp("sid_connection"));
dlog[Debug::INFO] << myname << ": add point " << n << ":" << n1 << endl; dlog.info() << myname << ": add point " << n << ":" << n1 << endl;
nlst.push_back(ni); nlst.push_back(ni);
} }
} }
...@@ -127,7 +127,7 @@ void UniExchange::execute() ...@@ -127,7 +127,7 @@ void UniExchange::execute()
err << myname << "(execute): Не дождались готовности SharedMemory к работе в течение " err << myname << "(execute): Не дождались готовности SharedMemory к работе в течение "
<< smReadyTimeout << " мсек"; << smReadyTimeout << " мсек";
unideb[Debug::CRIT] << err.str() << endl; ulog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -150,23 +150,23 @@ void UniExchange::execute() ...@@ -150,23 +150,23 @@ void UniExchange::execute()
bool ok = false; bool ok = false;
try try
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << ": connect to id=" << it->id << " node=" << it->node << endl; dlog.info() << myname << ": connect to id=" << it->id << " node=" << it->node << endl;
IOController_i::ShortMapSeq_var sseq = ui.getSensors( it->id, it->node ); IOController_i::ShortMapSeq_var sseq = ui.getSensors( it->id, it->node );
ok = true; ok = true;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << myname << " update sensors from id=" << it->id << " node=" << it->node << endl; dlog.info() << myname << " update sensors from id=" << it->id << " node=" << it->node << endl;
it->update(sseq,shm); it->update(sseq,shm);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::INFO] << myname << "(execute): " << ex << endl; dlog.info() << myname << "(execute): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
dlog[Debug::INFO] << myname << "(execute): catch ..." << endl; dlog.info() << myname << "(execute): catch ..." << endl;
} }
if( it->sidConnection != DefaultObjectId ) if( it->sidConnection != DefaultObjectId )
...@@ -177,15 +177,15 @@ void UniExchange::execute() ...@@ -177,15 +177,15 @@ void UniExchange::execute()
} }
catch(...) catch(...)
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.is_crit() )
dlog[Debug::CRIT]<< myname << "(execute): sensor not avalible " dlog.crit()<< myname << "(execute): sensor not avalible "
<< conf->oind->getNameById( it->sidConnection) << conf->oind->getNameById( it->sidConnection)
<< endl; << endl;
} }
} }
if( !ok && dlog.debugging(Debug::INFO) ) if( !ok && dlog.is_info() )
dlog[Debug::INFO] << myname << ": ****** cannot connect with node=" << it->node << endl; dlog.info() << myname << ": ****** cannot connect with node=" << it->node << endl;
} }
if( ptUpdate.checkTime() ) if( ptUpdate.checkTime() )
...@@ -234,11 +234,11 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI ...@@ -234,11 +234,11 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::INFO] << "(update): " << ex << endl; dlog.info() << "(update): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
dlog[Debug::INFO] << "(update): catch ..." << endl; dlog.info() << "(update): catch ..." << endl;
} }
} }
} }
...@@ -278,11 +278,11 @@ void UniExchange::updateLocalData() ...@@ -278,11 +278,11 @@ void UniExchange::updateLocalData()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::WARN] << "(update): " << ex << endl; dlog.warn() << "(update): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
dlog[Debug::WARN] << "(update): catch ..." << endl; dlog.warn() << "(update): catch ..." << endl;
} }
} }
...@@ -444,7 +444,7 @@ bool UniExchange::initItem( UniXML_iterator& it ) ...@@ -444,7 +444,7 @@ bool UniExchange::initItem( UniXML_iterator& it )
if( i.id == DefaultObjectId ) if( i.id == DefaultObjectId )
{ {
if( dlog ) if( dlog )
dlog[Debug::CRIT] << myname << "(initItem): Unknown ID for " dlog.crit() << myname << "(initItem): Unknown ID for "
<< it.getProp("name") << endl; << it.getProp("name") << endl;
return false; return false;
} }
...@@ -453,7 +453,7 @@ bool UniExchange::initItem( UniXML_iterator& it ) ...@@ -453,7 +453,7 @@ bool UniExchange::initItem( UniXML_iterator& it )
if( i.type == UniversalIO::UnknownIOType ) if( i.type == UniversalIO::UnknownIOType )
{ {
if( dlog ) if( dlog )
dlog[Debug::CRIT] << myname << "(initItem): Unknown iotype= " dlog.crit() << myname << "(initItem): Unknown iotype= "
<< it.getProp("iotype") << " for " << it.getProp("name") << endl; << it.getProp("iotype") << " for " << it.getProp("name") << endl;
return false; return false;
} }
......
...@@ -26,7 +26,7 @@ int main(int argc, const char **argv) ...@@ -26,7 +26,7 @@ int main(int argc, const char **argv)
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log"); string logfilename = conf->getArgParam("--logfile", "smemory.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
unideb.logFile( logname ); ulog.logFile( logname );
dlog.logFile( logname ); dlog.logFile( logname );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
...@@ -58,15 +58,15 @@ int main(int argc, const char **argv) ...@@ -58,15 +58,15 @@ int main(int argc, const char **argv)
} }
catch(SystemError& err) catch(SystemError& err)
{ {
unideb[Debug::CRIT] << "(uninetwork): " << err << endl; ulog.crit() << "(uninetwork): " << err << endl;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
unideb[Debug::CRIT] << "(uninetwork): " << ex << endl; ulog.crit() << "(uninetwork): " << ex << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] << "(uninetwork): catch(...)" << endl; ulog.crit() << "(uninetwork): catch(...)" << endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2013-12-15+04:00 // generate timestamp: 2013-12-17+04:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
......
...@@ -24,7 +24,7 @@ namespace UniSetExtensions ...@@ -24,7 +24,7 @@ namespace UniSetExtensions
{ {
ostringstream err; ostringstream err;
err << ": Unknown ID for '" << sname << "'" << endl; err << ": Unknown ID for '" << sname << "'" << endl;
dlog[Debug::CRIT] << err.str() << endl; dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -53,11 +53,11 @@ namespace UniSetExtensions ...@@ -53,11 +53,11 @@ namespace UniSetExtensions
if( heartBeatTime <= 0 ) if( heartBeatTime <= 0 )
{ {
heartBeatTime = 0; heartBeatTime = 0;
dlog[Debug::WARN] << "(getHeartBeatTime): механизм 'HEARTBEAT' ОТКЛЮЧЁН!" << endl; dlog.warn() << "(getHeartBeatTime): механизм 'HEARTBEAT' ОТКЛЮЧЁН!" << endl;
} }
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(getHeartBeatTime): heartbeat time = " << heartBeatTime << endl; dlog.info() << "(getHeartBeatTime): heartbeat time = " << heartBeatTime << endl;
return heartBeatTime; return heartBeatTime;
} }
...@@ -114,7 +114,7 @@ namespace UniSetExtensions ...@@ -114,7 +114,7 @@ namespace UniSetExtensions
{ {
ostringstream err; ostringstream err;
err << "(buildCalibrationDiagram): НЕ НАЙДЕН корневой узел для калибровочных диаграмм"; err << "(buildCalibrationDiagram): НЕ НАЙДЕН корневой узел для калибровочных диаграмм";
dlog[Debug::CRIT] << err.str() << endl; dlog.crit() << err.str() << endl;
throw SystemError( err.str()); throw SystemError( err.str());
} }
...@@ -123,7 +123,7 @@ namespace UniSetExtensions ...@@ -123,7 +123,7 @@ namespace UniSetExtensions
{ {
ostringstream err; ostringstream err;
err << "(buildCalibrationDiagram): НЕ НАЙДЕНА калибровочная диаграмма '" << dname << "'"; err << "(buildCalibrationDiagram): НЕ НАЙДЕНА калибровочная диаграмма '" << dname << "'";
dlog[Debug::CRIT] << err.str() << endl; dlog.crit() << err.str() << endl;
throw SystemError( err.str()); throw SystemError( err.str());
} }
......
...@@ -390,8 +390,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -390,8 +390,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
if( dlog ) if( dlog && dlog->is_crit() )
dlog[Debug::CRIT] << myname << "(readItem): (-1) Не удалось получить ID для датчика: " dlog->crit() << myname << "(readItem): (-1) Не удалось получить ID для датчика: "
<< sname << endl; << sname << endl;
return false; return false;
} }
...@@ -435,8 +435,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -435,8 +435,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
} }
else else
{ {
if( dlog ) if( dlog && dlog->is_crit() )
dlog[Debug::CRIT] << myname << "(IOBase::readItem): Unknown iofront='" << front_t << "'" dlog->crit() << myname << "(IOBase::readItem): Unknown iofront='" << front_t << "'"
<< " for '" << sname << "'. Must be [ 01, 10 ]." << endl; << " for '" << sname << "'. Must be [ 01, 10 ]." << endl;
return false; return false;
} }
...@@ -447,8 +447,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -447,8 +447,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
b->stype = UniSetTypes::getIOType(it.getProp("iotype")); b->stype = UniSetTypes::getIOType(it.getProp("iotype"));
if( b->stype == UniversalIO::UnknownIOType ) if( b->stype == UniversalIO::UnknownIOType )
{ {
if( dlog ) if( dlog && dlog->is_crit() )
dlog[Debug::CRIT] << myname << "(IOBase::readItem): неизвестный iotype=: " dlog->crit() << myname << "(IOBase::readItem): неизвестный iotype=: "
<< it.getProp("iotype") << " для " << sname << endl; << it.getProp("iotype") << " для " << sname << endl;
return false; return false;
} }
...@@ -534,8 +534,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -534,8 +534,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
b->t_ai = conf->getSensorID(tai); b->t_ai = conf->getSensorID(tai);
if( b->t_ai == DefaultObjectId ) if( b->t_ai == DefaultObjectId )
{ {
if( dlog ) if( dlog && dlog->is_crit() )
dlog[Debug::CRIT] << myname << "(IOBase::readItem): unknown ID for threshold_ai " dlog->crit() << myname << "(IOBase::readItem): unknown ID for threshold_ai "
<< tai << endl; << tai << endl;
return false; return false;
} }
...@@ -548,7 +548,7 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -548,7 +548,7 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
} }
// else // else
// { // {
// dlog[Debug::CRIT] << myname << "(IOBase::readItem): неизвестный iotype=: " << stype << " для " << sname << endl; // dlog.crit() << myname << "(IOBase::readItem): неизвестный iotype=: " << stype << " для " << sname << endl;
// return false; // return false;
// } // }
......
...@@ -51,24 +51,24 @@ using namespace UniSetTypes; ...@@ -51,24 +51,24 @@ using namespace UniSetTypes;
} \ } \
catch( IOController_i::NameNotFound &ex ) \ catch( IOController_i::NameNotFound &ex ) \
{ \ { \
unideb[Debug::WARN] << "(" << __STRING(fname) << "): " << ex.err << endl; \ ulog.warn() << "(" << __STRING(fname) << "): " << ex.err << endl; \
} \ } \
catch( IOController_i::IOBadParam &ex ) \ catch( IOController_i::IOBadParam &ex ) \
{ \ { \
unideb[Debug::WARN] << "(" << __STRING(fname) << "): " << ex.err << endl; \ ulog.warn() << "(" << __STRING(fname) << "): " << ex.err << endl; \
} \ } \
catch( Exception& ex ) \ catch( Exception& ex ) \
{ \ { \
unideb[Debug::WARN] << "(" << __STRING(fname) << "): " << ex << endl; \ ulog.warn() << "(" << __STRING(fname) << "): " << ex << endl; \
} \ } \
catch(CORBA::SystemException& ex) \ catch(CORBA::SystemException& ex) \
{ \ { \
unideb[Debug::WARN] << "(" << __STRING(fname) << "): CORBA::SystemException: " \ ulog.warn() << "(" << __STRING(fname) << "): CORBA::SystemException: " \
<< ex.NP_minorString() << endl; \ << ex.NP_minorString() << endl; \
} \ } \
catch(...) \ catch(...) \
{ \ { \
unideb[Debug::WARN] << "(" << __STRING(fname) << "): catch ..." << endl; \ ulog.warn() << "(" << __STRING(fname) << "): catch ..." << endl; \
} \ } \
\ \
oref = CORBA::Object::_nil(); \ oref = CORBA::Object::_nil(); \
...@@ -77,7 +77,7 @@ using namespace UniSetTypes; ...@@ -77,7 +77,7 @@ using namespace UniSetTypes;
#define CHECK_IC_PTR(fname) \ #define CHECK_IC_PTR(fname) \
if( !ic ) \ if( !ic ) \
{ \ { \
unideb[Debug::WARN] << "(" << __STRING(fname) << "): function NOT DEFINED..." << endl; \ ulog.warn() << "(" << __STRING(fname) << "): function NOT DEFINED..." << endl; \
throw UniSetTypes::TimeOut(); \ throw UniSetTypes::TimeOut(); \
} \ } \
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2013-12-15+04:00 // generate timestamp: 2013-12-17+04:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include "Configuration.h" #include "Configuration.h"
#include "Exceptions.h" #include "Exceptions.h"
...@@ -43,7 +43,7 @@ askPause(2000), ...@@ -43,7 +43,7 @@ askPause(2000),
end_private(false) end_private(false)
{ {
unideb[Debug::CRIT] << "UObject: init failed!!!!!!!!!!!!!!!" << endl; ulog.crit() << "UObject: init failed!!!!!!!!!!!!!!!" << endl;
throw Exception( string(myname+": init failed!!!") ); throw Exception( string(myname+": init failed!!!") );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -170,23 +170,27 @@ bool UObject_SK::alarm( UniSetTypes::ObjectId _code, bool _state ) ...@@ -170,23 +170,27 @@ bool UObject_SK::alarm( UniSetTypes::ObjectId _code, bool _state )
{ {
if( _code == UniSetTypes::DefaultObjectId ) if( _code == UniSetTypes::DefaultObjectId )
{ {
unideb[Debug::CRIT] << getName() if( ulog.is_crit() )
ulog.crit() << getName()
<< "(alarm): попытка послать сообщение с DefaultObjectId" << "(alarm): попытка послать сообщение с DefaultObjectId"
<< endl; << endl;
return false; return false;
} }
unideb[Debug::LEVEL1] << getName() << "(alarm): "; if( ulog.is_level1() )
{
ulog.level1() << getName() << "(alarm): ";
if( _state ) if( _state )
unideb(Debug::LEVEL1) << "SEND "; ulog.level1(false) << "SEND ";
else else
unideb(Debug::LEVEL1) << "RESET "; ulog.level1(false) << "RESET ";
unideb(Debug::LEVEL1) << endl;
ulog.level1(false) << endl;
}
if( ulog.is_level1() )
ulog.level1() << " not found MessgeOID?!!" << endl;
unideb[Debug::LEVEL1] << " not found MessgeOID?!!" << endl;
return false; return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -256,10 +260,11 @@ void UObject_SK::sysCommand( SystemMessage* _sm ) ...@@ -256,10 +260,11 @@ void UObject_SK::sysCommand( SystemMessage* _sm )
switch( _sm->command ) switch( _sm->command )
{ {
case SystemMessage::WatchDog: case SystemMessage::WatchDog:
unideb << myname << "(sysCommand): WatchDog" << endl; ulog << myname << "(sysCommand): WatchDog" << endl;
if( !active || !ptStartUpTimeout.checkTime() ) if( !active || !ptStartUpTimeout.checkTime() )
{ {
unideb[Debug::WARN] << myname << "(sysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl; if( ulog.is_warn() )
ulog.warn() << myname << "(sysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl;
break; break;
} }
case SystemMessage::StartUp: case SystemMessage::StartUp:
...@@ -285,12 +290,12 @@ void UObject_SK::sysCommand( SystemMessage* _sm ) ...@@ -285,12 +290,12 @@ void UObject_SK::sysCommand( SystemMessage* _sm )
case SystemMessage::LogRotate: case SystemMessage::LogRotate:
{ {
// переоткрываем логи // переоткрываем логи
unideb << myname << "(sysCommand): logRotate" << endl; ulog << myname << "(sysCommand): logRotate" << endl;
string fname = unideb.getLogFile(); string fname( ulog.getLogFile() );
if( !fname.empty() ) if( !fname.empty() )
{ {
unideb.logFile(fname.c_str()); ulog.logFile(fname.c_str());
unideb << myname << "(sysCommand): ***************** UNIDEB LOG ROTATE *****************" << endl; ulog << myname << "(sysCommand): ***************** ulog LOG ROTATE *****************" << endl;
} }
} }
break; break;
...@@ -336,9 +341,9 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID ) ...@@ -336,9 +341,9 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
if( _testID == DefaultObjectId ) if( _testID == DefaultObjectId )
return; return;
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
{ {
unideb[Debug::INFO] << myname << "(waitSM): waiting SM ready " ulog.info() << myname << "(waitSM): waiting SM ready "
<< wait_msec << " msec" << wait_msec << " msec"
<< " testID=" << _testID << endl; << " testID=" << _testID << endl;
} }
...@@ -350,7 +355,8 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID ) ...@@ -350,7 +355,8 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<< "(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение " << "(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<< wait_msec << " мсек"; << wait_msec << " мсек";
unideb[Debug::CRIT] << err.str() << endl; if( ulog.is_crit() )
ulog.crit() << err.str() << endl;
terminate(); terminate();
abort(); abort();
// kill(SIGTERM,getpid()); // прерываем (перезапускаем) процесс... // kill(SIGTERM,getpid()); // прерываем (перезапускаем) процесс...
...@@ -404,16 +410,19 @@ void UObject_SK::callback() ...@@ -404,16 +410,19 @@ void UObject_SK::callback()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(execute): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(execute): " << ex << endl;
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
unideb[Debug::CRIT] << myname << "(execute): СORBA::SystemException: " if( ulog.is_crit() )
ulog.crit() << myname << "(execute): СORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] << myname << "(execute): catch ..." << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(execute): catch ..." << endl;
} }
if( !active ) if( !active )
...@@ -450,14 +459,14 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid ) ...@@ -450,14 +459,14 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
try try
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(getValue): Обращение к неизвестному ДИСКРЕТНОМУ датчику sid=" ulog.crit() << myname << "(getValue): Обращение к неизвестному датчику sid="
<< _sid << endl; << _sid << endl;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(getValue): " << ex << endl; ulog.crit() << myname << "(getValue): " << ex << endl;
throw; throw;
} }
...@@ -476,8 +485,8 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd ) ...@@ -476,8 +485,8 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
break; break;
} }
if( !activated ) if( !activated && ulog.is_crit() )
unideb[Debug::CRIT] << myname ulog.crit() << myname
<< "(preAskSensors): ************* don`t activated?! ************" << endl; << "(preAskSensors): ************* don`t activated?! ************" << endl;
for( ;; ) for( ;; )
...@@ -489,15 +498,18 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd ) ...@@ -489,15 +498,18 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
} }
catch(SystemError& err) catch(SystemError& err)
{ {
unideb[Debug::CRIT] << myname << "(preAskSensors): " << err << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(preAskSensors): " << err << endl;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
unideb[Debug::CRIT] << myname << "(preAskSensors): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(preAskSensors): " << ex << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] << myname << "(preAskSensors): catch(...)" << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(preAskSensors): catch(...)" << endl;
} }
msleep(askPause); msleep(askPause);
} }
......
...@@ -26,7 +26,7 @@ int main(int argc, const char **argv) ...@@ -26,7 +26,7 @@ int main(int argc, const char **argv)
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log"); string logfilename = conf->getArgParam("--logfile", "smemory.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
unideb.logFile( logname ); ulog.logFile( logname );
dlog.logFile( logname ); dlog.logFile( logname );
SharedMemory* shm = SharedMemory::init_smemory(argc, argv); SharedMemory* shm = SharedMemory::init_smemory(argc, argv);
...@@ -49,19 +49,19 @@ int main(int argc, const char **argv) ...@@ -49,19 +49,19 @@ int main(int argc, const char **argv)
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
unideb[Debug::CRIT] << "(smemory): " << err << endl; ulog.crit() << "(smemory): " << err << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << "(smemory): " << ex << endl; ulog.crit() << "(smemory): " << ex << endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
unideb[Debug::CRIT] << "(smemory): " << e.what() << endl; ulog.crit() << "(smemory): " << e.what() << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::CRIT] << "(smemory): catch(...)" << endl; ulog.crit() << "(smemory): catch(...)" << endl;
} }
return 1; return 1;
......
...@@ -240,7 +240,7 @@ namespace UniSetTypes ...@@ -240,7 +240,7 @@ namespace UniSetTypes
extern Configuration* conf; extern Configuration* conf;
/*! Глобальный объект для вывода логов */ /*! Глобальный объект для вывода логов */
extern DebugStream unideb; extern DebugStream ulog;
// Инициализация UniSetTypes::conf. // Инициализация UniSetTypes::conf.
......
...@@ -108,6 +108,6 @@ void operator|=(Debug::type & d1, Debug::type d2) ...@@ -108,6 +108,6 @@ void operator|=(Debug::type & d1, Debug::type d2)
#include "DebugStream.h" #include "DebugStream.h"
std::ostream & operator<<(std::ostream & o, Debug::type t); std::ostream & operator<<(std::ostream & o, Debug::type t);
//extern DebugStream unideb; //extern DebugStream ulog;
#endif #endif
...@@ -58,7 +58,7 @@ struct Debug { ...@@ -58,7 +58,7 @@ struct Debug {
If you want to have debug output from time critical code you should If you want to have debug output from time critical code you should
use this construct: use this construct:
if (debug.debugging(Debug::INFO)) { if (debug..is_info()) {
debug << "...debug output...\n"; debug << "...debug output...\n";
} }
...@@ -117,12 +117,8 @@ public: ...@@ -117,12 +117,8 @@ public:
inline std::string getLogFile(){ return fname; } inline std::string getLogFile(){ return fname; }
/// Returns true if t is part of the current debug level. /// Returns true if t is part of the current debug level.
bool debugging(Debug::type t = Debug::ANY) const inline bool debugging(Debug::type t = Debug::ANY) const
{ { return (dt & t); }
if (dt & t) return true;
return false;
}
/** Returns the no-op stream if t is not part of the /** Returns the no-op stream if t is not part of the
current debug level otherwise the real debug stream current debug level otherwise the real debug stream
...@@ -146,26 +142,52 @@ public: ...@@ -146,26 +142,52 @@ public:
Вывод продолжения логов (без даты и времени) Вывод продолжения логов (без даты и времени)
*/ */
inline std::ostream& to_end(Debug::type t) inline std::ostream& to_end(Debug::type t)
{ { return this->operator()(t); }
return this->operator()(t);
}
/** /**
Вывод продолжения логов (без даты и времени) Вывод продолжения логов (без даты и времени) "log()"
*/ */
std::ostream& operator()(Debug::type t); std::ostream& operator()(Debug::type t);
inline void showDateTime(bool s) inline void showDateTime(bool s)
{ { show_datetime = s; }
show_datetime = s;
} // короткие функции (для удобства)
// log.level1() - вывод с датой и временем "date time [LEVEL] ...",
// если вывод даты и времени не выключен при помощи showDateTime(false)
std::ostream& print_date(Debug::type t, char brk='/'); // if( log.is_level1() ) - проверка включён ли лог.."
std::ostream& print_time(Debug::type t, char brk=':');
std::ostream& print_datetime(Debug::type t); #define DMANIP(FNAME,LEVEL) \
inline std::ostream& FNAME( bool showdatetime=true ) \
{\
if( showdatetime )\
return operator[](Debug::LEVEL); \
return operator()(Debug::LEVEL); \
} \
\
inline bool is_##FNAME() \
{ return debugging(Debug::LEVEL); }
DMANIP(level1,LEVEL1)
DMANIP(level2,LEVEL2)
DMANIP(level3,LEVEL3)
DMANIP(level4,LEVEL4)
DMANIP(level5,LEVEL5)
DMANIP(level6,LEVEL6)
DMANIP(level7,LEVEL7)
DMANIP(level8,LEVEL8)
DMANIP(level9,LEVEL9)
DMANIP(info,INFO)
DMANIP(warn,WARN)
DMANIP(crit,CRIT)
DMANIP(repository,REPOSITORY)
DMANIP(system,SYSTEM)
DMANIP(exception,EXCEPTION)
#undef DMANIP
std::ostream& printDate(Debug::type t, char brk='/');
std::ostream& printTime(Debug::type t, char brk=':');
std::ostream& printDateTime(Debug::type t);
std::ostream& pos(int x, int y); std::ostream& pos(int x, int y);
......
...@@ -105,7 +105,7 @@ class UniXML_iterator: ...@@ -105,7 +105,7 @@ class UniXML_iterator:
operator xmlNode*() operator xmlNode*()
{ {
//unideb << "current\n"; //ulog.< "current\n";
return curNode; return curNode;
} }
......
...@@ -237,7 +237,7 @@ long UModbus::data2value( VTypes::VType vtype, ModbusRTU::ModbusData* data ) ...@@ -237,7 +237,7 @@ long UModbus::data2value( VTypes::VType vtype, ModbusRTU::ModbusData* data )
return true; return true;
} }
dlog[Debug::CRIT] << myname << "(initSMValue): IGNORE item: rnum=" << p->rnum dlog.crit() << myname << "(initSMValue): IGNORE item: rnum=" << p->rnum
<< " > 1 ?!! for id=" << p->si.id << endl; << " > 1 ?!! for id=" << p->si.id << endl;
return false; return false;
......
...@@ -127,7 +127,7 @@ mbErrCode ModbusRTUMaster::sendData( unsigned char* buf, int len ) ...@@ -127,7 +127,7 @@ mbErrCode ModbusRTUMaster::sendData( unsigned char* buf, int len )
} }
catch( Exception& ex ) // SystemError catch( Exception& ex ) // SystemError
{ {
dlog[Debug::CRIT] << "(send): " << ex << endl; dlog.crit() << "(send): " << ex << endl;
return erHardwareError; return erHardwareError;
} }
......
...@@ -68,7 +68,7 @@ mbErrCode ModbusRTUSlave::receive( ModbusRTU::ModbusAddr addr, timeout_t timeout ...@@ -68,7 +68,7 @@ mbErrCode ModbusRTUSlave::receive( ModbusRTU::ModbusAddr addr, timeout_t timeout
if( !lck.lock_ok() ) if( !lck.lock_ok() )
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.debugging(Debug::CRIT) )
dlog[Debug::CRIT] << "(ModbusRTUSlave::receive): Don`t lock " << recvMutex << endl; dlog.crit() << "(ModbusRTUSlave::receive): Don`t lock " << recvMutex << endl;
return erTimeOut; return erTimeOut;
} }
...@@ -89,7 +89,7 @@ mbErrCode ModbusRTUSlave::receive( ModbusRTU::ModbusAddr addr, timeout_t timeout ...@@ -89,7 +89,7 @@ mbErrCode ModbusRTUSlave::receive( ModbusRTU::ModbusAddr addr, timeout_t timeout
printProcessingTime(); printProcessingTime();
} }
// dlog[Debug::WARN] << "(receive): " << mbErr2Str(res) << endl; // dlog.warn() << "(receive): " << mbErr2Str(res) << endl;
// cerr << "**** (receive): " << mbErr2Str(res) << endl; // cerr << "**** (receive): " << mbErr2Str(res) << endl;
usleep(10000); usleep(10000);
return res; return res;
...@@ -151,7 +151,7 @@ mbErrCode ModbusRTUSlave::sendData( unsigned char* buf, int len ) ...@@ -151,7 +151,7 @@ mbErrCode ModbusRTUSlave::sendData( unsigned char* buf, int len )
} }
catch( Exception& ex ) // SystemError catch( Exception& ex ) // SystemError
{ {
dlog[Debug::CRIT] << "(send): " << ex << endl; dlog.crit() << "(send): " << ex << endl;
return erHardwareError; return erHardwareError;
} }
......
...@@ -54,22 +54,22 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -54,22 +54,22 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
{ {
if( iaddr.empty() ) if( iaddr.empty() )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << iaddr << "(ModbusTCPMaster::query): unknown ip address for server..." << endl; dlog.warn() << iaddr << "(ModbusTCPMaster::query): unknown ip address for server..." << endl;
return erTimeOut; // erHardwareError return erTimeOut; // erHardwareError
} }
if( !isConnection() ) if( !isConnection() )
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << iaddr << "(ModbusTCPMaster::query): no connection.. reconnnect..." << endl; dlog.info() << iaddr << "(ModbusTCPMaster::query): no connection.. reconnnect..." << endl;
reconnect(); reconnect();
} }
if( !isConnection() ) if( !isConnection() )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << iaddr << "(ModbusTCPMaster::query): not connected to server..." << endl; dlog.warn() << iaddr << "(ModbusTCPMaster::query): not connected to server..." << endl;
return erTimeOut; return erTimeOut;
} }
...@@ -95,9 +95,9 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -95,9 +95,9 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
mh.swapdata(); mh.swapdata();
// send TCP header // send TCP header
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
{ {
dlog[Debug::INFO] << iaddr << "(ModbusTCPMaster::query): send tcp header(" << sizeof(mh) <<"): "; dlog.info() << iaddr << "(ModbusTCPMaster::query): send tcp header(" << sizeof(mh) <<"): ";
mbPrintMessage( dlog, (ModbusByte*)(&mh), sizeof(mh)); mbPrintMessage( dlog, (ModbusByte*)(&mh), sizeof(mh));
dlog(Debug::INFO) << endl; dlog(Debug::INFO) << endl;
} }
...@@ -114,20 +114,20 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -114,20 +114,20 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
if( tcp->isPending(ost::Socket::pendingOutput,timeout) ) if( tcp->isPending(ost::Socket::pendingOutput,timeout) )
break; break;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPMaster::query): no write pending.. reconnnect.." << endl; dlog.info() << "(ModbusTCPMaster::query): no write pending.. reconnnect.." << endl;
reconnect(); reconnect();
if( !isConnection() ) if( !isConnection() )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(ModbusTCPMaster::query): not connected to server..." << endl; dlog.warn() << "(ModbusTCPMaster::query): not connected to server..." << endl;
return erTimeOut; return erTimeOut;
} }
cleanInputStream(); cleanInputStream();
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPMaster::query): no write pending.. reconnnect OK" << endl; dlog.info() << "(ModbusTCPMaster::query): no write pending.. reconnnect OK" << endl;
} }
mh.swapdata(); mh.swapdata();
...@@ -160,18 +160,18 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -160,18 +160,18 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
*/ */
ModbusTCP::MBAPHeader rmh; ModbusTCP::MBAPHeader rmh;
int ret = getNextData((unsigned char*)(&rmh),sizeof(rmh)); int ret = getNextData((unsigned char*)(&rmh),sizeof(rmh));
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
{ {
dlog[Debug::INFO] << "(ModbusTCPMaster::query): recv tcp header(" << ret << "): "; dlog.info() << "(ModbusTCPMaster::query): recv tcp header(" << ret << "): ";
mbPrintMessage( dlog, (ModbusByte*)(&rmh), sizeof(rmh)); mbPrintMessage( dlog, (ModbusByte*)(&rmh), sizeof(rmh));
dlog(Debug::INFO) << endl; dlog.info(false) << endl;
} }
if( ret < (int)sizeof(rmh) ) if( ret < (int)sizeof(rmh) )
{ {
ost::tpport_t port; ost::tpport_t port;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPMaster::query): ret=" << (int)ret dlog.info() << "(ModbusTCPMaster::query): ret=" << (int)ret
<< " < rmh=" << (int)sizeof(rmh) << " < rmh=" << (int)sizeof(rmh)
<< " err: " << tcp->getErrorNumber() << " err: " << tcp->getErrorNumber()
<< " perr: " << tcp->getPeer(&port) << " perr: " << tcp->getPeer(&port)
...@@ -201,8 +201,8 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -201,8 +201,8 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
if( force_disconnect ) if( force_disconnect )
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(query): force disconnect.." << endl; dlog.info() << "(query): force disconnect.." << endl;
disconnect(); disconnect();
} }
...@@ -210,13 +210,13 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -210,13 +210,13 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
return res; return res;
} }
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(query): input pending timeout " << endl; dlog.info() << "(query): input pending timeout " << endl;
if( force_disconnect ) if( force_disconnect )
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(query): force disconnect.." << endl; dlog.info() << "(query): force disconnect.." << endl;
// cleanInputStream(); // cleanInputStream();
disconnect(); disconnect();
...@@ -226,35 +226,35 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg, ...@@ -226,35 +226,35 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(query): " << ex << endl; dlog.warn() << "(query): " << ex << endl;
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(query): " << err << endl; dlog.warn() << "(query): " << err << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(query): " << ex << endl; dlog.warn() << "(query): " << ex << endl;
} }
catch( ost::SockException& e ) catch( ost::SockException& e )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(query): tcp error: " << e.getString() << endl; dlog.warn() << "(query): tcp error: " << e.getString() << endl;
return erTimeOut; return erTimeOut;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::CRIT] << "(query): " << e.what() << std::endl; dlog.crit() << "(query): " << e.what() << std::endl;
return erTimeOut; return erTimeOut;
} }
catch(...) catch(...)
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.is_warn() )
dlog[Debug::WARN] << "(query): cath..." << endl; dlog.warn() << "(query): cath..." << endl;
} }
return erTimeOut; // erHardwareError return erTimeOut; // erHardwareError
...@@ -295,8 +295,8 @@ bool ModbusTCPMaster::checkConnection( const std::string ip, int port, int timeo ...@@ -295,8 +295,8 @@ bool ModbusTCPMaster::checkConnection( const std::string ip, int port, int timeo
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPMaster::reconnect() void ModbusTCPMaster::reconnect()
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPMaster): reconnect " << iaddr << endl; dlog.info() << "(ModbusTCPMaster): reconnect " << iaddr << endl;
if( tcp ) if( tcp )
{ {
...@@ -320,7 +320,7 @@ void ModbusTCPMaster::reconnect() ...@@ -320,7 +320,7 @@ void ModbusTCPMaster::reconnect()
{ {
ostringstream s; ostringstream s;
s << "(ModbusTCPMaster): connection " << s.str() << " error: " << e.what(); s << "(ModbusTCPMaster): connection " << s.str() << " error: " << e.what();
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
} }
} }
catch( ... ) catch( ... )
...@@ -329,7 +329,7 @@ void ModbusTCPMaster::reconnect() ...@@ -329,7 +329,7 @@ void ModbusTCPMaster::reconnect()
{ {
ostringstream s; ostringstream s;
s << "(ModbusTCPMaster): connection " << s.str() << " error: catch ..."; s << "(ModbusTCPMaster): connection " << s.str() << " error: catch ...";
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
} }
} }
} }
...@@ -354,8 +354,8 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port ) ...@@ -354,8 +354,8 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
ostringstream s; ostringstream s;
s << addr << ":" << port; s << addr << ":" << port;
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPMaster): connect to " << s.str() << endl; dlog.info() << "(ModbusTCPMaster): connect to " << s.str() << endl;
iaddr = s.str(); iaddr = s.str();
...@@ -371,7 +371,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port ) ...@@ -371,7 +371,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
{ {
ostringstream s; ostringstream s;
s << "(ModbusTCPMaster): connection " << s.str() << " error: " << e.what(); s << "(ModbusTCPMaster): connection " << s.str() << " error: " << e.what();
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
} }
} }
catch( ... ) catch( ... )
...@@ -380,7 +380,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port ) ...@@ -380,7 +380,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
{ {
ostringstream s; ostringstream s;
s << "(ModbusTCPMaster): connection " << s.str() << " error: catch ..."; s << "(ModbusTCPMaster): connection " << s.str() << " error: catch ...";
dlog[Debug::CRIT] << s.str() << std::endl; dlog.crit() << s.str() << std::endl;
} }
} }
// } // }
...@@ -388,8 +388,8 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port ) ...@@ -388,8 +388,8 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPMaster::disconnect() void ModbusTCPMaster::disconnect()
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << iaddr << "(ModbusTCPMaster): disconnect." << endl; dlog.info() << iaddr << "(ModbusTCPMaster): disconnect." << endl;
if( !tcp ) if( !tcp )
return; return;
......
...@@ -183,9 +183,9 @@ mbErrCode ModbusTCPServer::tcp_processing( ost::TCPStream& tcp, ModbusTCP::MBAPH ...@@ -183,9 +183,9 @@ mbErrCode ModbusTCPServer::tcp_processing( ost::TCPStream& tcp, ModbusTCP::MBAPH
mhead.swapdata(); mhead.swapdata();
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
{ {
dlog[Debug::INFO] << "(ModbusTCPServer::tcp_processing): recv tcp header(" << len << "): "; dlog.info() << "(ModbusTCPServer::tcp_processing): recv tcp header(" << len << "): ";
mbPrintMessage( dlog, (ModbusByte*)(&mhead), sizeof(mhead)); mbPrintMessage( dlog, (ModbusByte*)(&mhead), sizeof(mhead));
dlog(Debug::INFO) << endl; dlog(Debug::INFO) << endl;
} }
...@@ -198,8 +198,8 @@ mbErrCode ModbusTCPServer::tcp_processing( ost::TCPStream& tcp, ModbusTCP::MBAPH ...@@ -198,8 +198,8 @@ mbErrCode ModbusTCPServer::tcp_processing( ost::TCPStream& tcp, ModbusTCP::MBAPH
if( len<mhead.len ) if( len<mhead.len )
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPServer::tcp_processing): len(" << (int)len dlog.info() << "(ModbusTCPServer::tcp_processing): len(" << (int)len
<< ") < mhead.len(" << (int)mhead.len << ")" << endl; << ") < mhead.len(" << (int)mhead.len << ")" << endl;
return erInvalidFormat; return erInvalidFormat;
...@@ -219,9 +219,9 @@ mbErrCode ModbusTCPServer::pre_send_request( ModbusMessage& request ) ...@@ -219,9 +219,9 @@ mbErrCode ModbusTCPServer::pre_send_request( ModbusMessage& request )
curQueryHeader.len -= szCRC; curQueryHeader.len -= szCRC;
curQueryHeader.swapdata(); curQueryHeader.swapdata();
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
{ {
dlog[Debug::INFO] << "(ModbusTCPServer::pre_send_request): send tcp header: "; dlog.info() << "(ModbusTCPServer::pre_send_request): send tcp header: ";
mbPrintMessage( dlog, (ModbusByte*)(&curQueryHeader), sizeof(curQueryHeader)); mbPrintMessage( dlog, (ModbusByte*)(&curQueryHeader), sizeof(curQueryHeader));
dlog(Debug::INFO) << endl; dlog(Debug::INFO) << endl;
} }
...@@ -245,8 +245,8 @@ void ModbusTCPServer::cleanInputStream() ...@@ -245,8 +245,8 @@ void ModbusTCPServer::cleanInputStream()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPServer::terminate() void ModbusTCPServer::terminate()
{ {
if( dlog.debugging(Debug::INFO) ) if( dlog.is_info() )
dlog[Debug::INFO] << "(ModbusTCPServer): terminate..." << endl; dlog.info() << "(ModbusTCPServer): terminate..." << endl;
if( tcp && tcp.isConnected() ) if( tcp && tcp.isConnected() )
tcp.disconnect(); tcp.disconnect();
......
...@@ -54,7 +54,7 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string sior ...@@ -54,7 +54,7 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string sior
if( !ior_file ) if( !ior_file )
{ {
unideb[Debug::CRIT] << "(IORFile): не смог открыть файл "+fname << endl; ulog.crit() << "(IORFile): не смог открыть файл "+fname << endl;
throw TimeOut("(IORFile): не смог создать ior-файл "+fname); throw TimeOut("(IORFile): не смог создать ior-файл "+fname);
} }
......
...@@ -45,8 +45,8 @@ namespace ORepHelpers ...@@ -45,8 +45,8 @@ namespace ORepHelpers
CosNaming::NamingContext_ptr getContext(const string& cname, int argc, const char* const* argv, const string& nsName )throw(ORepFailed) CosNaming::NamingContext_ptr getContext(const string& cname, int argc, const char* const* argv, const string& nsName )throw(ORepFailed)
{ {
CORBA::ORB_var orb = CORBA::ORB_init( argc, (char**)argv ); CORBA::ORB_var orb = CORBA::ORB_init( argc, (char**)argv );
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELP: orb init ok"<< endl; ulog.repository() << "OREPHELP: orb init ok"<< endl;
return getContext(orb, cname, nsName); return getContext(orb, cname, nsName);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -54,25 +54,26 @@ namespace ORepHelpers ...@@ -54,25 +54,26 @@ namespace ORepHelpers
{ {
CosNaming::NamingContext_var rootC; CosNaming::NamingContext_var rootC;
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELPER(getContext): get rootcontext...(servname = "<< servname << ")" <<endl; ulog.repository() << "OREPHELPER(getContext): get rootcontext...(servname = "<< servname << ")" <<endl;
rootC = getRootNamingContext(orb, servname); rootC = getRootNamingContext(orb, servname);
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELPER(getContext): get rootContect ok " << endl; ulog.repository() << "OREPHELPER(getContext): get rootContect ok " << endl;
if( CORBA::is_nil(rootC) ) if( CORBA::is_nil(rootC) )
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "OREPHELPER: не смог получить ссылку на NameServices"<< endl; if( ulog.is_warn() )
ulog.warn() << "OREPHELPER: не смог получить ссылку на NameServices"<< endl;
throw ORepFailed("OREPHELPER(getContext): не смог получить ссылку на NameServices"); throw ORepFailed("OREPHELPER(getContext): не смог получить ссылку на NameServices");
} }
if ( cname.empty() ) if ( cname.empty() )
return rootC._retn(); return rootC._retn();
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELPER(getContext): get ref context " << cname << endl; ulog.repository() << "OREPHELPER(getContext): get ref context " << cname << endl;
CosNaming::Name_var ctxName = omniURI::stringToName(cname.c_str()); CosNaming::Name_var ctxName = omniURI::stringToName(cname.c_str());
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
...@@ -90,14 +91,16 @@ namespace ORepHelpers ...@@ -90,14 +91,16 @@ namespace ORepHelpers
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): не смог получить ссылку на контекст " << cname; err << "OREPHELPER(getContext): не смог получить ссылку на контекст " << cname;
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << err.str() << endl; if( ulog.is_warn() )
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(const CosNaming::NamingContext::NotFound &nf) catch(const CosNaming::NamingContext::NotFound &nf)
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): не найден контекст " << cname; err << "OREPHELPER(getContext): не найден контекст " << cname;
unideb[Debug::WARN] << err.str() << endl; if( ulog.warn() )
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(const CosNaming::NamingContext::CannotProceed &np) catch(const CosNaming::NamingContext::CannotProceed &np)
...@@ -105,34 +108,40 @@ namespace ORepHelpers ...@@ -105,34 +108,40 @@ namespace ORepHelpers
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): catch CannotProced " << cname; err << "OREPHELPER(getContext): catch CannotProced " << cname;
err << " bad part=" << omniURI::nameToString(np.rest_of_name); err << " bad part=" << omniURI::nameToString(np.rest_of_name);
unideb[Debug::WARN] << err.str() << endl; if( ulog.is_warn() )
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): поймали CORBA::SystemException: " << ex.NP_minorString(); err << "OREPHELPER(getContext): поймали CORBA::SystemException: " << ex.NP_minorString();
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << err.str() << endl; if( ulog.is_warn() )
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(CORBA::Exception&) catch(CORBA::Exception&)
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "OREPHELPER(getContext): поймали CORBA::Exception." << endl; if( ulog.is_warn() )
ulog.warn() << "OREPHELPER(getContext): поймали CORBA::Exception." << endl;
throw ORepFailed(); throw ORepFailed();
} }
catch(omniORB::fatalException& fe) catch(omniORB::fatalException& fe)
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): поймали omniORB::fatalException:"; err << "OREPHELPER(getContext): поймали omniORB::fatalException:";
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << err << endl; if( ulog.is_warn() )
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << " file: " << fe.file() << endl; {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << " line: " << fe.line() << endl; ulog.warn() << err << endl;
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << " mesg: " << fe.errmsg() << endl; ulog.warn() << " file: " << fe.file() << endl;
ulog.warn() << " line: " << fe.line() << endl;
ulog.warn() << " mesg: " << fe.errmsg() << endl;
}
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "getContext: получили "<< cname << endl; ulog.repository() << "getContext: получили "<< cname << endl;
// Если _var // Если _var
// return CosNaming::NamingContext::_duplicate(ctx); // return CosNaming::NamingContext::_duplicate(ctx);
...@@ -151,8 +160,8 @@ namespace ORepHelpers ...@@ -151,8 +160,8 @@ namespace ORepHelpers
{ {
// cout << "ORepHelpers(getRootNamingContext): nsName->" << nsName << endl; // cout << "ORepHelpers(getRootNamingContext): nsName->" << nsName << endl;
CORBA::Object_var initServ = orb->resolve_initial_references(nsName.c_str()); CORBA::Object_var initServ = orb->resolve_initial_references(nsName.c_str());
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELP: get rootcontext...(nsName = "<< nsName << ")" <<endl; ulog.repository() << "OREPHELP: get rootcontext...(nsName = "<< nsName << ")" <<endl;
rootContext = CosNaming::NamingContext::_narrow(initServ); rootContext = CosNaming::NamingContext::_narrow(initServ);
if (CORBA::is_nil(rootContext)) if (CORBA::is_nil(rootContext))
...@@ -161,14 +170,15 @@ namespace ORepHelpers ...@@ -161,14 +170,15 @@ namespace ORepHelpers
throw ORepFailed(err.c_str()); throw ORepFailed(err.c_str());
} }
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELP: init NameService ok"<< endl; ulog.repository() << "OREPHELP: init NameService ok"<< endl;
} }
catch(CORBA::ORB::InvalidName& ex) catch(CORBA::ORB::InvalidName& ex)
{ {
ostringstream err; ostringstream err;
err << "ORepHelpers(getRootNamingContext): InvalidName=" << nsName; err << "ORepHelpers(getRootNamingContext): InvalidName=" << nsName;
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << err.str() << endl; if( ulog.is_warn() )
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch (CORBA::COMM_FAILURE& ex) catch (CORBA::COMM_FAILURE& ex)
...@@ -188,8 +198,8 @@ namespace ORepHelpers ...@@ -188,8 +198,8 @@ namespace ORepHelpers
throw ORepFailed(err); throw ORepFailed(err);
} }
if( unideb.debugging(Debug::REPOSITORY) ) if( ulog.is_repository() )
unideb[Debug::REPOSITORY] << "OREPHELP: get root context ok"<< endl; ulog.repository() << "OREPHELP: get root context ok"<< endl;
// // Если создан как _ptr // // Если создан как _ptr
// return rootContext; // return rootContext;
......
...@@ -119,12 +119,12 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec, ...@@ -119,12 +119,12 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
{ {
if( (unsigned)ind >= omap.size() ) if( (unsigned)ind >= omap.size() )
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size(); msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str()); // throw OutOfRange(msg.str());
unideb[Debug::WARN] << msg.str() << "... Делаем resize + 100\n"; ulog.warn() << msg.str() << "... Делаем resize + 100\n";
} }
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
...@@ -135,7 +135,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec, ...@@ -135,7 +135,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build):: не нашли параметр RootSection в конф. файле "; msg << "(ObjectIndex_XML::build):: не нашли параметр RootSection в конф. файле ";
unideb[Debug::CRIT] << msg.str() << endl; ulog.crit() << msg.str() << endl;
throw SystemError(msg.str()); throw SystemError(msg.str());
} }
...@@ -199,12 +199,13 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec, ...@@ -199,12 +199,13 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
if( (unsigned)ind >= omap.size() ) if( (unsigned)ind >= omap.size() )
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size(); msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str()); // throw OutOfRange(msg.str());
unideb[Debug::INFO] << msg.str() << "... Делаем resize + 100\n"; if( ulog.is_info() )
ulog.info() << msg.str() << "... Делаем resize + 100\n";
} }
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
...@@ -220,7 +221,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string sec, un ...@@ -220,7 +221,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string sec, un
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size(); msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str()); // throw OutOfRange(msg.str());
unideb[Debug::WARN] << msg.str() << "... Делаем resize + 100\n"; ulog.warn() << msg.str() << "... Делаем resize + 100\n";
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
...@@ -276,7 +277,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string sec, un ...@@ -276,7 +277,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string sec, un
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size(); msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str()); // throw OutOfRange(msg.str());
unideb[Debug::WARN] << msg.str() << "... Делаем resize + 100\n"; ulog.warn() << msg.str() << "... Делаем resize + 100\n";
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
} }
......
...@@ -93,7 +93,7 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string sec ) ...@@ -93,7 +93,7 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string sec )
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_idXML::build):: не нашли параметр RootSection в конф. файле "; msg << "(ObjectIndex_idXML::build):: не нашли параметр RootSection в конф. файле ";
unideb[Debug::CRIT] << msg.str() << endl; ulog.crit() << msg.str() << endl;
throw SystemError(msg.str()); throw SystemError(msg.str());
} }
......
...@@ -98,8 +98,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -98,8 +98,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
{ {
ostringstream err; ostringstream err;
if( unideb.debugging(Debug::type(Debug::INFO|Debug::REPOSITORY)) ) if( ulog.is_info() )
unideb[Debug::type(Debug::INFO|Debug::REPOSITORY)] << "ObjectRepository(registration): регистрируем " << name << endl; ulog.info() << "ObjectRepository(registration): регистрируем " << name << endl;
// Проверка корректности имени // Проверка корректности имени
char bad = ORepHelpers::checkBadSymbols(name); char bad = ORepHelpers::checkBadSymbols(name);
...@@ -127,8 +127,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -127,8 +127,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
} }
catch(const CosNaming::NamingContext::AlreadyBound &nf) catch(const CosNaming::NamingContext::AlreadyBound &nf)
{ {
if( unideb.debugging(Debug::type(Debug::WARN|Debug::REPOSITORY)) ) if( ulog.is_warn() )
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "(registration): "<< name <<" уже зарегестрирован в "<< section << "!!!" << endl; ulog.warn() << "(registration): "<< name <<" уже зарегестрирован в "<< section << "!!!" << endl;
if( !force ) if( !force )
throw ObjectNameAlready(); throw ObjectNameAlready();
...@@ -136,35 +136,6 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -136,35 +136,6 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
// разрегистриуем, перед повтроной попыткой // разрегистриуем, перед повтроной попыткой
ctx->unbind(oName); ctx->unbind(oName);
continue; continue;
/*
// делаем проверку жив ли объект
bool life(false);
try
{
unideb[Debug::type(Debug::INFO|Debug::REPOSITORY)] << "(registration): " << name << " уже есть... проверяем живой ли? "<< endl;
CORBA::Object_var ref = ctx->resolve(oName);
UniSetObject_i_var uobj = UniSetObject_i::_narrow(ref);
uobj->getId(); // пытаемся вызвать функцию (любую), если не сможет сработает исключение
life = true;
unideb[Debug::type(Debug::INFO|Debug::REPOSITORY)] << "(registration): " << name << " живой! "<< endl;
}
catch(...)
{
life=false;
}
if( !life )
{
unideb(Debug::type(Debug::WARN|Debug::REPOSITORY)) << "(registration): " << name << " ЕСТЬ в репозитории, но недоступен. Заменяем на новую ссылку "<< endl;
ctx->rebind(oName, oRef);
}
else
{
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "(registration): "<< name <<" уже зарегестрирован в "<< section<< "!!!!!!!!!!!" << endl;
throw ObjectNameAlready();
}
return;
*/
} }
catch(ORepFailed) catch(ORepFailed)
{ {
...@@ -186,14 +157,15 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -186,14 +157,15 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "ObjectRepository(registrartion): поймали CORBA::SystemException: " if( ulog.is_warn() )
ulog.warn() << "ObjectRepository(registrartion): поймали CORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
err << "ObjectRepository(registrartion): поймали CORBA::SystemException: " << ex.NP_minorString(); err << "ObjectRepository(registrartion): поймали CORBA::SystemException: " << ex.NP_minorString();
} }
// catch(...) // catch(...)
// { // {
// unideb[Debug::WARN] << "поймали что-то неизвестное..."<< endl; // ulog.warn() << "поймали что-то неизвестное..."<< endl;
// } // }
} }
...@@ -231,23 +203,23 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy ...@@ -231,23 +203,23 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy
void ObjectRepository::unregistration(const string& name, const string& section) void ObjectRepository::unregistration(const string& name, const string& section)
throw(ORepFailed, NameNotFound) throw(ORepFailed, NameNotFound)
{ {
// unideb[Debug::INFO] << "OREP: unregistration "<< name << " из "<< section << endl; // ulog.info() << "OREP: unregistration "<< name << " из "<< section << endl;
ostringstream err; ostringstream err;
CosNaming::Name_var oName = omniURI::stringToName(name.c_str()); CosNaming::Name_var oName = omniURI::stringToName(name.c_str());
// unideb[Debug::INFO] << "OREP: string to name ok"<< endl; // ulog.info() << "OREP: string to name ok"<< endl;
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
CORBA::ORB_var orb = uconf->getORB(); CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName); ctx = ORepHelpers::getContext(orb, section, nsName);
// unideb[Debug::INFO] << "OREP: get context " << section <<" ok"<< endl; // ulog.info() << "OREP: get context " << section <<" ok"<< endl;
try try
{ {
// Удаляем запись об объекте // Удаляем запись об объекте
ctx->unbind(oName); ctx->unbind(oName);
// unideb[Debug::INFO] << "OREP: ok" << endl; // ulog.info() << "OREP: ok" << endl;
return; return;
} }
catch(const CosNaming::NamingContext::NotFound &nf) catch(const CosNaming::NamingContext::NotFound &nf)
...@@ -372,7 +344,7 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName *ls ...@@ -372,7 +344,7 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName *ls
bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned int how_many, ObjectType type) bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned int how_many, ObjectType type)
{ {
// Возвращает false если вынут не весь список... // Возвращает false если вынут не весь список...
// unideb[Debug::INFO] << "получаем список из "<< section << endl; // ulog.info() << "получаем список из "<< section << endl;
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
try try
{ {
...@@ -381,14 +353,14 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned ...@@ -381,14 +353,14 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned
} }
catch(ORepFailed) catch(ORepFailed)
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "ORepository(list): не смог получить ссылку на "<< section << endl; ulog.warn() << "ORepository(list): не смог получить ссылку на "<< section << endl;
throw; throw;
// return false; // return false;
} }
if( CORBA::is_nil(ctx) ) if( CORBA::is_nil(ctx) )
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "ORepository(list): не смог получить ссылку на "<< section << endl; ulog.warn() << "ORepository(list): не смог получить ссылку на "<< section << endl;
throw ORepFailed(); throw ORepFailed();
} }
...@@ -463,10 +435,10 @@ bool ObjectRepository::isExist( ObjectPtr oref ) ...@@ -463,10 +435,10 @@ bool ObjectRepository::isExist( ObjectPtr oref )
catch(CORBA::Exception&){} catch(CORBA::Exception&){}
catch(omniORB::fatalException& fe) catch(omniORB::fatalException& fe)
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "ObjectRepository(isExist): "<< "поймали omniORB::fatalException:" << endl; ulog.warn() << "ObjectRepository(isExist): "<< "поймали omniORB::fatalException:" << endl;
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << " file: " << fe.file() << endl; ulog.warn() << " file: " << fe.file() << endl;
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << " line: " << fe.line() << endl; ulog.warn() << " line: " << fe.line() << endl;
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << " mesg: " << fe.errmsg() << endl; ulog.warn() << " mesg: " << fe.errmsg() << endl;
} }
catch(...){} catch(...){}
......
...@@ -64,10 +64,11 @@ bool ObjectRepositoryFactory::createSection( const char* name, const char* in_se ...@@ -64,10 +64,11 @@ bool ObjectRepositoryFactory::createSection( const char* name, const char* in_se
throw ( InvalidObjectName(err.str().c_str()) ); throw ( InvalidObjectName(err.str().c_str()) );
} }
unideb[Debug::REPOSITORY] << "CreateSection: name = "<< name << " in section = " << in_section << endl; ulog.repository() << "CreateSection: name = "<< name << " in section = " << in_section << endl;
if( sizeof(in_section)==0 ) if( sizeof(in_section)==0 )
{ {
unideb[Debug::REPOSITORY] << "CreateSection: in_section=0"<< endl; if( ulog.repository() )
ulog.repository() << "CreateSection: in_section=0"<< endl;
return createRootSection(name); return createRootSection(name);
} }
...@@ -92,13 +93,16 @@ bool ObjectRepositoryFactory::createSectionF(const string& fullName)throw(ORepFa ...@@ -92,13 +93,16 @@ bool ObjectRepositoryFactory::createSectionF(const string& fullName)throw(ORepFa
string name(ObjectIndex::getBaseName(fullName)); string name(ObjectIndex::getBaseName(fullName));
string sec(ORepHelpers::getSectionName(fullName)); string sec(ORepHelpers::getSectionName(fullName));
unideb[Debug::REPOSITORY] << name << endl; ulog.repository() << name << endl;
unideb[Debug::REPOSITORY] << sec << endl; ulog.repository() << sec << endl;
if ( sec.empty() ) if ( sec.empty() )
{ {
unideb[Debug::REPOSITORY] << "SectionName is empty!!!"<< endl; if( ulog.repository() )
unideb[Debug::REPOSITORY] << "Добавляем в "<< uconf->getRootSection() << endl; {
ulog.repository() << "SectionName is empty!!!"<< endl;
ulog.repository() << "Добавляем в "<< uconf->getRootSection() << endl;
}
return createSection(name, uconf->getRootSection()); return createSection(name, uconf->getRootSection());
} }
else else
...@@ -125,49 +129,59 @@ bool ObjectRepositoryFactory::createContext(const char *cname, CosNaming::Naming ...@@ -125,49 +129,59 @@ bool ObjectRepositoryFactory::createContext(const char *cname, CosNaming::Naming
CosNaming::Name_var nc = omniURI::stringToName(cname); CosNaming::Name_var nc = omniURI::stringToName(cname);
try try
{ {
unideb[Debug::REPOSITORY] << "ORepFactory(createContext): создаю новый контекст "<< cname << endl; if( ulog.repository() )
ulog.repository() << "ORepFactory(createContext): создаю новый контекст "<< cname << endl;
ctx->bind_new_context(nc); ctx->bind_new_context(nc);
unideb[Debug::REPOSITORY] << "ORepFactory(createContext): создал. " << endl; if( ulog.repository() )
ulog.repository() << "ORepFactory(createContext): создал. " << endl;
return true; return true;
} }
catch(const CosNaming::NamingContext::AlreadyBound &ab) catch(const CosNaming::NamingContext::AlreadyBound &ab)
{ {
// ctx->resolve(nc); // ctx->resolve(nc);
unideb[Debug::REPOSITORY] <<"ORepFactory(createContext): context "<< cname << " уже есть"<< endl; if( ulog.repository() )
ulog.repository() <<"ORepFactory(createContext): context "<< cname << " уже есть"<< endl;
return true; return true;
} }
catch(CosNaming::NamingContext::NotFound) catch(CosNaming::NamingContext::NotFound)
{ {
unideb[Debug::REPOSITORY] <<"ORepFactory(createContext): NotFound "<< cname << endl; if( ulog.repository() )
ulog.repository() <<"ORepFactory(createContext): NotFound "<< cname << endl;
throw NameNotFound(); throw NameNotFound();
} }
catch(const CosNaming::NamingContext::InvalidName &nf) catch(const CosNaming::NamingContext::InvalidName &nf)
{ {
// unideb[Debug::WARN] << "invalid name"<< endl; if( ulog.is_warn() )
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "ORepFactory(createContext): (InvalidName) " << cname; ulog.warn() << "ORepFactory(createContext): (InvalidName) " << cname;
} }
catch(const CosNaming::NamingContext::CannotProceed &cp) catch(const CosNaming::NamingContext::CannotProceed &cp)
{ {
unideb[Debug::type(Debug::WARN|Debug::REPOSITORY)] << "ORepFactory(createContext): catch CannotProced " if( ulog.is_crit() )
ulog.warn() << "ORepFactory(createContext): catch CannotProced "
<< cname << " bad part=" << cname << " bad part="
<< omniURI::nameToString(cp.rest_of_name); << omniURI::nameToString(cp.rest_of_name);
throw NameNotFound(); throw NameNotFound();
} }
catch( CORBA::SystemException& ex) catch( CORBA::SystemException& ex)
{ {
unideb[Debug::type(Debug::CRIT|Debug::REPOSITORY)] << "ORepFactory(createContext): CORBA::SystemException: " if( ulog.is_crit() )
ulog.crit() << "ORepFactory(createContext): CORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
catch(CORBA::Exception&) catch(CORBA::Exception&)
{ {
unideb[Debug::type(Debug::CRIT|Debug::REPOSITORY)] << "поймали CORBA::Exception." << endl; if( ulog.is_crit() )
ulog.crit() << "поймали CORBA::Exception." << endl;
} }
catch(omniORB::fatalException& fe) catch(omniORB::fatalException& fe)
{ {
unideb[Debug::type(Debug::CRIT|Debug::REPOSITORY)] << "поймали omniORB::fatalException:" << endl; if( ulog.is_crit() )
unideb[Debug::type(Debug::CRIT|Debug::REPOSITORY)] << " file: " << fe.file() << endl; {
unideb[Debug::type(Debug::CRIT|Debug::REPOSITORY)] << " line: " << fe.line() << endl; ulog.crit() << "поймали omniORB::fatalException:" << endl;
unideb[Debug::type(Debug::CRIT|Debug::REPOSITORY)] << " mesg: " << fe.errmsg() << endl; ulog.crit() << " file: " << fe.file() << endl;
ulog.crit() << " line: " << fe.line() << endl;
ulog.crit() << " mesg: " << fe.errmsg() << endl;
}
} }
return false; return false;
...@@ -253,19 +267,19 @@ bool ObjectRepositoryFactory::removeSection(const string& fullName, bool recursi ...@@ -253,19 +267,19 @@ bool ObjectRepositoryFactory::removeSection(const string& fullName, bool recursi
if( recursive ) if( recursive )
{ {
unideb[Debug::REPOSITORY] << "ORepFactory: удаляем рекурсивно..." << endl; ulog.repository() << "ORepFactory: удаляем рекурсивно..." << endl;
string rctx = fullName+"/"+omniURI::nameToString(bl[i].binding_name); string rctx = fullName+"/"+omniURI::nameToString(bl[i].binding_name);
unideb[Debug::REPOSITORY] << rctx << endl; ulog.repository() << rctx << endl;
if ( !removeSection(rctx)) if ( !removeSection(rctx))
{ {
unideb[Debug::REPOSITORY] << "рекурсивно удалить не удалось" << endl; ulog.repository() << "рекурсивно удалить не удалось" << endl;
rem = false; rem = false;
} }
} }
else else
{ {
unideb[Debug::REPOSITORY] << "ORepFactory: " << omniURI::nameToString(bl[i].binding_name) << " - контекст!!! "; ulog.repository() << "ORepFactory: " << omniURI::nameToString(bl[i].binding_name) << " - контекст!!! ";
unideb[Debug::REPOSITORY] << "ORepFactory: пока не удаляем" << endl; ulog.repository() << "ORepFactory: пока не удаляем" << endl;
rem = false; rem = false;
} }
} }
...@@ -291,12 +305,12 @@ bool ObjectRepositoryFactory::removeSection(const string& fullName, bool recursi ...@@ -291,12 +305,12 @@ bool ObjectRepositoryFactory::removeSection(const string& fullName, bool recursi
} }
catch(const CosNaming::NamingContext::NotEmpty &ne) catch(const CosNaming::NamingContext::NotEmpty &ne)
{ {
unideb[Debug::REPOSITORY] << "ORepFactory: контекст" << fullName << " не пустой " << endl; ulog.repository() << "ORepFactory: контекст" << fullName << " не пустой " << endl;
rem = false; rem = false;
} }
catch( ORepFailed ) catch( ORepFailed )
{ {
unideb[Debug::REPOSITORY] << "ORepFactory: не удаось получить ссылку на контекст " << in_sec << endl; ulog.repository() << "ORepFactory: не удаось получить ссылку на контекст " << in_sec << endl;
rem=false; rem=false;
} }
} }
...@@ -322,8 +336,8 @@ bool ObjectRepositoryFactory::renameSection( const string& newFName, const strin ...@@ -322,8 +336,8 @@ bool ObjectRepositoryFactory::renameSection( const string& newFName, const strin
try try
{ {
// unideb[Debug::REPOSITORY] << "ORepFactory: в контексте "<< in_sec << endl; // ulog.repository() << "ORepFactory: в контексте "<< in_sec << endl;
// unideb[Debug::REPOSITORY] << "ORepFactory: переименовываем " << oldFName << " в " << newFName << endl; // ulog.repository() << "ORepFactory: переименовываем " << oldFName << " в " << newFName << endl;
int argc(uconf->getArgc()); int argc(uconf->getArgc());
const char * const* argv(uconf->getArgv()); const char * const* argv(uconf->getArgv());
CosNaming::NamingContext_var in_ctx = ORepHelpers::getContext(in_sec, argc, argv, nsName); CosNaming::NamingContext_var in_ctx = ORepHelpers::getContext(in_sec, argc, argv, nsName);
......
...@@ -137,7 +137,7 @@ void ObjectsManager::initPOA( ObjectsManager* rmngr ) ...@@ -137,7 +137,7 @@ void ObjectsManager::initPOA( ObjectsManager* rmngr )
poa = rmngr->getPOA(); poa = rmngr->getPOA();
if( CORBA::is_nil(poa) ) if( CORBA::is_nil(poa) )
unideb[Debug::CRIT] << myname << "(initPOA): failed init poa " << endl; ulog.crit() << myname << "(initPOA): failed init poa " << endl;
// Инициализация самого менеджера и его подобъектов // Инициализация самого менеджера и его подобъектов
UniSetObject::init(rmngr); UniSetObject::init(rmngr);
...@@ -152,8 +152,8 @@ bool ObjectsManager::addObject( UniSetObject *obj ) ...@@ -152,8 +152,8 @@ bool ObjectsManager::addObject( UniSetObject *obj )
ObjectsList::iterator li=find(olist.begin(),olist.end(), obj); ObjectsList::iterator li=find(olist.begin(),olist.end(), obj);
if( li==olist.end() ) if( li==olist.end() )
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname << "(activator): добавляем объект "<< obj->getName()<< endl; ulog.info() << myname << "(activator): добавляем объект "<< obj->getName()<< endl;
olist.push_back(obj); olist.push_back(obj);
} }
} // unlock } // unlock
...@@ -168,28 +168,28 @@ bool ObjectsManager::removeObject(UniSetObject* obj) ...@@ -168,28 +168,28 @@ bool ObjectsManager::removeObject(UniSetObject* obj)
ObjectsList::iterator li=find(olist.begin(),olist.end(), obj); ObjectsList::iterator li=find(olist.begin(),olist.end(), obj);
if( li!=olist.end() ) if( li!=olist.end() )
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname << "(activator): удаляем объект "<< obj->getName()<< endl; ulog.info() << myname << "(activator): удаляем объект "<< obj->getName()<< endl;
try try
{ {
obj->disactivate(); obj->disactivate();
} }
catch(Exception& ex) catch(Exception& ex)
{ {
unideb[Debug::WARN] << myname << "(removeObject): " << ex << endl; ulog.warn() << myname << "(removeObject): " << ex << endl;
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
unideb[Debug::WARN] << myname << "(removeObject): поймали CORBA::SystemException: " << ex.NP_minorString() << endl; ulog.warn() << myname << "(removeObject): поймали CORBA::SystemException: " << ex.NP_minorString() << endl;
} }
catch(CORBA::Exception& ex) catch(CORBA::Exception& ex)
{ {
unideb[Debug::WARN] << myname << "(removeObject): CORBA::Exception" << endl; ulog.warn() << myname << "(removeObject): CORBA::Exception" << endl;
} }
catch( omniORB::fatalException& fe ) catch( omniORB::fatalException& fe )
{ {
unideb[Debug::CRIT] << myname << "(managers): Caught omniORB::fatalException:" << endl; ulog.crit() << myname << "(managers): Caught omniORB::fatalException:" << endl;
unideb[Debug::CRIT] << myname << "(managers): file: " << fe.file() ulog.crit() << myname << "(managers): file: " << fe.file()
<< " line: " << fe.line() << " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl; << " mesg: " << fe.errmsg() << endl;
} }
...@@ -208,8 +208,8 @@ bool ObjectsManager::removeObject(UniSetObject* obj) ...@@ -208,8 +208,8 @@ bool ObjectsManager::removeObject(UniSetObject* obj)
*/ */
void ObjectsManager::managers(OManagerCommand cmd) void ObjectsManager::managers(OManagerCommand cmd)
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname <<"(managers): mlist.size=" ulog.info() << myname <<"(managers): mlist.size="
<< mlist.size() << " cmd=" << cmd << endl; << mlist.size() << " cmd=" << cmd << endl;
{ //lock { //lock
uniset_rwmutex_rlock lock(mlistMutex); uniset_rwmutex_rlock lock(mlistMutex);
...@@ -241,28 +241,28 @@ void ObjectsManager::managers(OManagerCommand cmd) ...@@ -241,28 +241,28 @@ void ObjectsManager::managers(OManagerCommand cmd)
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(managers): " << ex << endl; ulog.crit() << myname << "(managers): " << ex << endl;
unideb[Debug::CRIT] << myname << "(managers): не смог зарегистрировать (разрегистрировать) объект -->"<< (*li)->getName() << endl; ulog.crit() << myname << "(managers): не смог зарегистрировать (разрегистрировать) объект -->"<< (*li)->getName() << endl;
} }
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(managers): поймали CORBA::SystemException:" << ex.NP_minorString() << endl; ulog.crit() << myname << "(managers): поймали CORBA::SystemException:" << ex.NP_minorString() << endl;
} }
catch( CORBA::Exception& ex ) catch( CORBA::Exception& ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(managers): Caught CORBA::Exception. " << ex._name() << endl; ulog.crit() << myname << "(managers): Caught CORBA::Exception. " << ex._name() << endl;
} }
catch( omniORB::fatalException& fe ) catch( omniORB::fatalException& fe )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(managers): Caught omniORB::fatalException:" << endl; ulog.crit() << myname << "(managers): Caught omniORB::fatalException:" << endl;
unideb[Debug::CRIT] << myname << "(managers): file: " << fe.file() ulog.crit() << myname << "(managers): file: " << fe.file()
<< " line: " << fe.line() << " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl; << " mesg: " << fe.errmsg() << endl;
} }
...@@ -276,8 +276,8 @@ void ObjectsManager::managers(OManagerCommand cmd) ...@@ -276,8 +276,8 @@ void ObjectsManager::managers(OManagerCommand cmd)
*/ */
void ObjectsManager::objects(OManagerCommand cmd) void ObjectsManager::objects(OManagerCommand cmd)
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname <<"(objects): olist.size=" ulog.info() << myname <<"(objects): olist.size="
<< olist.size() << " cmd=" << cmd << endl; << olist.size() << " cmd=" << cmd << endl;
{ //lock { //lock
uniset_rwmutex_rlock lock(olistMutex); uniset_rwmutex_rlock lock(olistMutex);
...@@ -310,30 +310,30 @@ void ObjectsManager::objects(OManagerCommand cmd) ...@@ -310,30 +310,30 @@ void ObjectsManager::objects(OManagerCommand cmd)
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(objects): " << ex << endl; ulog.crit() << myname << "(objects): " << ex << endl;
unideb[Debug::CRIT] << myname << "(objects): не смог зарегистрировать (разрегистрировать) объект -->"<< (*li)->getName() << endl; ulog.crit() << myname << "(objects): не смог зарегистрировать (разрегистрировать) объект -->"<< (*li)->getName() << endl;
} }
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(objects): поймали CORBA::SystemException:" << ex.NP_minorString() << endl; ulog.crit() << myname << "(objects): поймали CORBA::SystemException:" << ex.NP_minorString() << endl;
} }
catch( CORBA::Exception& ex ) catch( CORBA::Exception& ex )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
unideb[Debug::CRIT] << myname << "(objects): Caught CORBA::Exception. " ulog.crit() << myname << "(objects): Caught CORBA::Exception. "
<< ex._name() << ex._name()
<< " (" << (*li)->getName() << ")" << endl; << " (" << (*li)->getName() << ")" << endl;
} }
catch( omniORB::fatalException& fe ) catch( omniORB::fatalException& fe )
{ {
if( unideb.debugging(Debug::CRIT) ) if( ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(objects): Caught omniORB::fatalException:" << endl; ulog.crit() << myname << "(objects): Caught omniORB::fatalException:" << endl;
unideb[Debug::CRIT] << myname << "(objects): file: " << fe.file() ulog.crit() << myname << "(objects): file: " << fe.file()
<< " line: " << fe.line() << " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl; << " mesg: " << fe.errmsg() << endl;
} }
...@@ -348,8 +348,8 @@ void ObjectsManager::objects(OManagerCommand cmd) ...@@ -348,8 +348,8 @@ void ObjectsManager::objects(OManagerCommand cmd)
*/ */
bool ObjectsManager::activateObject() bool ObjectsManager::activateObject()
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname << "(activateObjects): активизирую объекты"<< endl; ulog.info() << myname << "(activateObjects): активизирую объекты"<< endl;
UniSetObject::activateObject(); UniSetObject::activateObject();
managers(activ); managers(activ);
objects(activ); objects(activ);
...@@ -362,8 +362,8 @@ bool ObjectsManager::activateObject() ...@@ -362,8 +362,8 @@ bool ObjectsManager::activateObject()
*/ */
bool ObjectsManager::disactivateObject() bool ObjectsManager::disactivateObject()
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname << "(disactivateObjects): деактивизирую объекты"<< endl; ulog.info() << myname << "(disactivateObjects): деактивизирую объекты"<< endl;
// именно в такой последовательности! // именно в такой последовательности!
objects(deactiv); objects(deactiv);
managers(deactiv); managers(deactiv);
...@@ -372,7 +372,7 @@ bool ObjectsManager::disactivateObject() ...@@ -372,7 +372,7 @@ bool ObjectsManager::disactivateObject()
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void ObjectsManager::sigterm( int signo ) void ObjectsManager::sigterm( int signo )
{ {
// unideb[Debug::INFO] << "ObjectsActivator: default processing signo="<< signo << endl; // ulog.info() << "ObjectsActivator: default processing signo="<< signo << endl;
sig=signo; sig=signo;
objects(term); objects(term);
managers(term); managers(term);
...@@ -409,11 +409,11 @@ bool ObjectsManager::addManager( ObjectsManager *child ) ...@@ -409,11 +409,11 @@ bool ObjectsManager::addManager( ObjectsManager *child )
if(it == mlist.end() ) if(it == mlist.end() )
{ {
mlist.push_back( child ); mlist.push_back( child );
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
unideb[Debug::INFO] << myname << ": добавляем менеджер "<< child->getName()<< endl; ulog.info() << myname << ": добавляем менеджер "<< child->getName()<< endl;
} }
else if( unideb.debugging(Debug::WARN) ) else if( ulog.is_warn() )
unideb[Debug::WARN] << myname << ": попытка повторного добавления объекта "<< child->getName() << endl; ulog.warn() << myname << ": попытка повторного добавления объекта "<< child->getName() << endl;
} // unlock } // unlock
return true; return true;
...@@ -505,11 +505,11 @@ int ObjectsManager::getObjectsInfo( ObjectsManager* mngr, SimpleInfoSeq* seq, ...@@ -505,11 +505,11 @@ int ObjectsManager::getObjectsInfo( ObjectsManager* mngr, SimpleInfoSeq* seq,
} }
catch(CORBA::Exception& ex) catch(CORBA::Exception& ex)
{ {
unideb[Debug::WARN] << myname << "(getObjectsInfo): CORBA::Exception" << endl; ulog.warn() << myname << "(getObjectsInfo): CORBA::Exception" << endl;
} }
catch(...) catch(...)
{ {
unideb[Debug::WARN] << myname << "(getObjectsInfo): не смог получить у объекта " ulog.warn() << myname << "(getObjectsInfo): не смог получить у объекта "
<< conf->oind->getNameById( (*it)->getId() ) << " информацию" << endl; << conf->oind->getNameById( (*it)->getId() ) << " информацию" << endl;
} }
} }
......
...@@ -61,7 +61,7 @@ void ObjectsManager_LT::callback() ...@@ -61,7 +61,7 @@ void ObjectsManager_LT::callback()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
unideb[Debug::CRIT] << myname << "(callback): " << ex << endl; ulog.crit() << myname << "(callback): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
......
...@@ -117,13 +117,13 @@ void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg ) ...@@ -117,13 +117,13 @@ void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg )
} }
default: default:
//unideb[Debug::WARN] << myname << ": неизвестное сообщение " << msg->type << endl; //ulog.warn() << myname << ": неизвестное сообщение " << msg->type << endl;
break; break;
} }
} }
catch(Exception& ex) catch(Exception& ex)
{ {
// unideb[Debug::WARN] // ulog.warn()
// cerr << myname << "(processingMessage): " << ex << endl; // cerr << myname << "(processingMessage): " << ex << endl;
} }
} }
......
...@@ -48,7 +48,7 @@ void ProxyManager::attachObject( PassiveObject* po, UniSetTypes::ObjectId id ) ...@@ -48,7 +48,7 @@ void ProxyManager::attachObject( PassiveObject* po, UniSetTypes::ObjectId id )
{ {
if( id == DefaultObjectId ) if( id == DefaultObjectId )
{ {
unideb[Debug::WARN] << myname << "(attachObject): попытка добавить объект с id=" ulog.warn() << myname << "(attachObject): попытка добавить объект с id="
<< DefaultObjectId << " PassiveObject=" << po->getName() << endl; << DefaultObjectId << " PassiveObject=" << po->getName() << endl;
return; return;
...@@ -81,9 +81,9 @@ bool ProxyManager::activateObject() ...@@ -81,9 +81,9 @@ bool ProxyManager::activateObject()
{ {
try try
{ {
if( unideb.debugging(Debug::INFO) ) if( ulog.is_info() )
{ {
unideb[Debug::INFO] << myname << "(registered): попытка " ulog.info() << myname << "(registered): попытка "
<< i+1 << " регистриую (id=" << it->first << ") " << i+1 << " регистриую (id=" << it->first << ") "
<< " (pname=" << it->second->getName() << ") " << " (pname=" << it->second->getName() << ") "
<< conf->oind->getNameById(it->first) << endl; << conf->oind->getNameById(it->first) << endl;
...@@ -93,21 +93,24 @@ bool ProxyManager::activateObject() ...@@ -93,21 +93,24 @@ bool ProxyManager::activateObject()
} }
catch( UniSetTypes::ObjectNameAlready& ex ) catch( UniSetTypes::ObjectNameAlready& ex )
{ {
unideb[Debug::CRIT] << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl;
try try
{ {
ui.unregister(it->first); ui.unregister(it->first);
} }
catch(Exception & ex) catch(Exception & ex)
{ {
unideb[Debug::CRIT] << myname << "(unregistered): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(unregistered): " << ex << endl;
} }
} }
} }
} }
catch(Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(activate): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(activate): " << ex << endl;
} }
} }
...@@ -124,7 +127,8 @@ bool ProxyManager::disactivateObject() ...@@ -124,7 +127,8 @@ bool ProxyManager::disactivateObject()
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(activate): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(activate): " << ex << endl;
} }
} }
...@@ -146,9 +150,9 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg ) ...@@ -146,9 +150,9 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg )
PObjectMap::iterator it = omap.find(msg->consumer); PObjectMap::iterator it = omap.find(msg->consumer);
if( it!=omap.end() ) if( it!=omap.end() )
it->second->processingMessage(msg); it->second->processingMessage(msg);
else else if( ulog.is_crit() )
{ {
unideb[Debug::CRIT] << myname << "(processingMessage): не найден объект " ulog.crit() << myname << "(processingMessage): не найден объект "
<< " consumer= " << msg->consumer << endl; << " consumer= " << msg->consumer << endl;
} }
} }
...@@ -157,7 +161,8 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg ) ...@@ -157,7 +161,8 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(processingMessage): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(processingMessage): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -171,7 +176,8 @@ void ProxyManager::allMessage( UniSetTypes::VoidMessage* msg ) ...@@ -171,7 +176,8 @@ void ProxyManager::allMessage( UniSetTypes::VoidMessage* msg )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(allMessage): " << ex << endl; if( ulog.is_crit() )
ulog.crit() << myname << "(allMessage): " << ex << endl;
} }
} }
} }
......
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