Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
1ac2fe0b
Commit
1ac2fe0b
authored
Sep 27, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogSession): добавил логов
(codegen): добавил вывод информации о LogServer-е
parent
5653c604
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
24 deletions
+36
-24
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+2
-0
libuniset2.spec
conf/libuniset2.spec
+5
-1
LogServer.cc
src/Log/LogServer.cc
+6
-1
LogSession.cc
src/Log/LogSession.cc
+23
-22
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
1ac2fe0b
...
...
@@ -494,6 +494,8 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo( CORBA:
inf
<<
i->info
<<
endl;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl;
if( logserv /*
&&
userparam
<
0 */ )
inf
<<
" "
<<
logserv->getShortInfo()
<<
endl;
inf
<<
dumpIO()
<<
endl;
inf
<<
endl;
auto timers = getTimersList();
...
...
conf/libuniset2.spec
View file @
1ac2fe0b
...
...
@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.5
Release: alt1
5
Release: alt1
6
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
...
...
@@ -486,6 +486,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Tue Sep 27 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt16
- LogSession: add more logs
- codegen: add logserver information in getInfo()
* Tue Sep 20 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt15
- up build
...
...
src/Log/LogServer.cc
View file @
1ac2fe0b
...
...
@@ -255,7 +255,12 @@ string LogServer::getShortInfo()
{
ostringstream
inf
;
inf
<<
"LogServer: "
<<
myname
<<
endl
;
inf
<<
"LogServer: "
<<
myname
<<
" ["
<<
" sessMaxCount="
<<
sessMaxCount
<<
" ]"
<<
endl
;
{
uniset_rwmutex_wrlock
l
(
mutSList
);
...
...
src/Log/LogSession.cc
View file @
1ac2fe0b
...
...
@@ -74,7 +74,7 @@ LogSession::LogSession( const Poco::Net::StreamSocket& s, std::shared_ptr<DebugS
if
(
iaddr
.
host
().
toString
().
empty
()
)
{
ostringstream
err
;
err
<<
"(
ModbusTCP
Session): unknonwn ip(0.0.0.0) client disconnected?!"
;
err
<<
"(
Log
Session): unknonwn ip(0.0.0.0) client disconnected?!"
;
if
(
mylog
.
is_crit
()
)
mylog
.
crit
()
<<
err
.
str
()
<<
endl
;
...
...
@@ -107,7 +107,7 @@ LogSession::LogSession( const Poco::Net::StreamSocket& s, std::shared_ptr<DebugS
if
(
log
)
conn
=
log
->
signal_stream_event
().
connect
(
sigc
::
mem_fun
(
this
,
&
LogSession
::
logOnEvent
)
);
else
mylog
.
crit
()
<<
"LOG NULL!!"
<<
endl
;
mylog
.
crit
()
<<
"
(LogSession):
LOG NULL!!"
<<
endl
;
}
// -------------------------------------------------------------------------
void
LogSession
::
logOnEvent
(
const
std
::
string
&
s
)
noexcept
...
...
@@ -141,7 +141,7 @@ void LogSession::logOnEvent( const std::string& s ) noexcept
if
(
!
lostMsg
)
{
ostringstream
err
;
err
<<
"The buffer is full. Message is lost...(size of buffer "
<<
maxRecordsNum
<<
")"
<<
endl
;
err
<<
"
(LogSession):
The buffer is full. Message is lost...(size of buffer "
<<
maxRecordsNum
<<
")"
<<
endl
;
logbuf
.
emplace
(
new
UTCPCore
::
Buffer
(
std
::
move
(
err
.
str
())));
lostMsg
=
true
;
}
...
...
@@ -163,7 +163,7 @@ void LogSession::run( const ev::loop_ref& loop ) noexcept
setSessionLogLevel
(
Debug
::
ANY
);
if
(
mylog
.
is_info
()
)
mylog
.
info
()
<<
peername
<<
"(run): run session.."
<<
endl
;
mylog
.
info
()
<<
peername
<<
"(
LogSession::
run): run session.."
<<
endl
;
asyncEvent
.
set
(
loop
);
cmdTimer
.
set
(
loop
);
...
...
@@ -178,7 +178,7 @@ void LogSession::run( const ev::loop_ref& loop ) noexcept
void
LogSession
::
terminate
()
{
if
(
mylog
.
is_info
()
)
mylog
.
info
()
<<
peername
<<
"(terminate)..."
<<
endl
;
mylog
.
info
()
<<
peername
<<
"(
LogSession::
terminate)..."
<<
endl
;
cancelled
=
true
;
...
...
@@ -196,6 +196,7 @@ void LogSession::terminate()
logbuf
.
pop
();
}
sock
->
disconnect
();
sock
->
close
();
final
();
}
...
...
@@ -205,7 +206,7 @@ void LogSession::event( ev::async& watcher, int revents ) noexcept
if
(
EV_ERROR
&
revents
)
{
if
(
mylog
.
is_crit
()
)
mylog
.
crit
()
<<
peername
<<
"(event): EVENT ERROR.."
<<
endl
;
mylog
.
crit
()
<<
peername
<<
"(
LogSession::
event): EVENT ERROR.."
<<
endl
;
return
;
}
...
...
@@ -218,7 +219,7 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
if
(
EV_ERROR
&
revents
)
{
if
(
mylog
.
is_crit
()
)
mylog
.
crit
()
<<
peername
<<
"(callback): EVENT ERROR.."
<<
endl
;
mylog
.
crit
()
<<
peername
<<
"(
LogSession::
callback): EVENT ERROR.."
<<
endl
;
return
;
}
...
...
@@ -241,10 +242,10 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
catch
(...){}
}
if
(
cancelled
)
if
(
cancelled
.
load
()
)
{
if
(
mylog
.
is_info
()
)
mylog
.
info
()
<<
peername
<<
": stop session... disconnect.."
<<
endl
;
mylog
.
info
()
<<
peername
<<
"
LogSession
: stop session... disconnect.."
<<
endl
;
io
.
stop
();
cmdTimer
.
stop
();
...
...
@@ -262,7 +263,7 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
// -------------------------------------------------------------------------
void
LogSession
::
writeEvent
(
ev
::
io
&
watcher
)
{
if
(
cancelled
)
if
(
cancelled
.
load
()
)
return
;
UTCPCore
::
Buffer
*
buffer
=
0
;
...
...
@@ -283,17 +284,17 @@ void LogSession::writeEvent( ev::io& watcher )
if
(
!
buffer
)
return
;
ssize_t
ret
=
write
(
watcher
.
fd
,
buffer
->
dpos
(),
buffer
->
nbytes
());
ssize_t
ret
=
::
write
(
watcher
.
fd
,
buffer
->
dpos
(),
buffer
->
nbytes
());
if
(
ret
<
0
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(writeEvent): write to socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(
LogSession::
writeEvent): write to socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
if
(
errno
==
EPIPE
)
if
(
errno
==
EPIPE
||
errno
==
EBADF
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(writeEvent): write error.. terminate session.."
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(
LogSession::
writeEvent): write error.. terminate session.."
<<
endl
;
cancelled
=
true
;
}
...
...
@@ -344,7 +345,7 @@ size_t LogSession::readData( unsigned char* buf, int len )
if
(
res
<
0
)
{
if
(
errno
!=
EAGAIN
&&
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(readData): read from socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(
LogSession::
readData): read from socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
return
0
;
}
...
...
@@ -362,7 +363,7 @@ size_t LogSession::readData( unsigned char* buf, int len )
}
mylog
.
info
()
<<
peername
<<
"(readData): client disconnected.."
<<
endl
;
mylog
.
info
()
<<
peername
<<
"(
LogSession::
readData): client disconnected.."
<<
endl
;
cancelled
=
true
;
return
0
;
}
...
...
@@ -382,13 +383,13 @@ void LogSession::readEvent( ev::io& watcher ) noexcept
if
(
ret
!=
sizeof
(
msg
)
||
msg
.
magic
!=
LogServerTypes
::
MAGICNUM
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(readEvent): BAD MESSAGE..."
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(
LogSession::
readEvent): BAD MESSAGE..."
<<
endl
;
return
;
}
if
(
mylog
.
is_info
()
)
mylog
.
info
()
<<
peername
<<
"(readEvent): receive command: '"
<<
msg
.
cmd
<<
"'"
<<
endl
;
mylog
.
info
()
<<
peername
<<
"(
LogSession::
readEvent): receive command: '"
<<
msg
.
cmd
<<
"'"
<<
endl
;
string
cmdLogName
(
msg
.
logname
);
...
...
@@ -399,7 +400,7 @@ void LogSession::readEvent( ev::io& watcher ) noexcept
catch
(
std
::
exception
&
ex
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(readEvent): "
<<
ex
.
what
()
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(
LogSession::
readEvent): "
<<
ex
.
what
()
<<
endl
;
}
catch
(...){}
...
...
@@ -550,7 +551,7 @@ void LogSession::cmdProcessing( const string& cmdLogName, const LogServerTypes::
catch
(
std
::
exception
&
ex
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(cmdProcessing): "
<<
ex
.
what
()
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(
LogSession::
cmdProcessing): "
<<
ex
.
what
()
<<
endl
;
}
}
// -------------------------------------------------------------------------
...
...
@@ -559,7 +560,7 @@ void LogSession::onCmdTimeout( ev::timer& watcher, int revents ) noexcept
if
(
EV_ERROR
&
revents
)
{
if
(
mylog
.
is_crit
()
)
mylog
.
crit
()
<<
peername
<<
"(onCmdTimeout): EVENT ERROR.."
<<
endl
;
mylog
.
crit
()
<<
peername
<<
"(
LogSession::
onCmdTimeout): EVENT ERROR.."
<<
endl
;
return
;
}
...
...
@@ -573,7 +574,7 @@ void LogSession::onCheckConnectionTimer( ev::timer& watcher, int revents ) noexc
if
(
EV_ERROR
&
revents
)
{
if
(
mylog
.
is_crit
()
)
mylog
.
crit
()
<<
peername
<<
"(onCheckConnectionTimer): EVENT ERROR.."
<<
endl
;
mylog
.
crit
()
<<
peername
<<
"(
LogSession::
onCheckConnectionTimer): EVENT ERROR.."
<<
endl
;
return
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment