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
010be9bd
Commit
010be9bd
authored
Nov 06, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogServer): добавил получение информации о текущем состоянии
в формате json (для http api)
parent
61c03c90
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
3 deletions
+49
-3
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+2
-2
start_fg.sh
Utilities/codegen/tests/start_fg.sh
+1
-1
LogServer.h
include/LogServer.h
+2
-0
LogSession.h
include/LogSession.h
+2
-0
LogServer.cc
src/Log/LogServer.cc
+19
-0
LogSession.cc
src/Log/LogSession.cc
+23
-0
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
010be9bd
...
...
@@ -574,9 +574,9 @@ nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpGet( const Poco::URI:
jdata["LogServer"] = {
{"host",logserv_host},
{"port",logserv_port},
{"state",( logserv->isRunning() ? "RUNNIG" : "STOPPED" )}
{"state",( logserv->isRunning() ? "RUNNIG" : "STOPPED" )},
{"info", logserv->httpGetShortInfo() }
};
// logserv->getShortInfo()
}
else
jdata["LogServer"] = {};
...
...
Utilities/codegen/tests/start_fg.sh
View file @
010be9bd
...
...
@@ -3,7 +3,7 @@
ulimit
-Sc
1000000
uniset2-start.sh
-f
./test
--name
TestProc
--confile
test.xml
--ulog-add-levels
system,warn,crit
\
--test-sm-ready-timeout
15000
--test-run-logserver
--test-logserver-host
192.192.192.192
$*
--test-sm-ready-timeout
15000
--test-run-logserver
$*
#--test-log-add-levels any $*
#info,warn,crit,system,level9 > 1.log
...
...
include/LogServer.h
View file @
010be9bd
...
...
@@ -29,6 +29,7 @@
#include "UTCPSocket.h"
#include "CommonEventLoop.h"
#include "LogServerTypes.h"
#include "json.hpp"
// -------------------------------------------------------------------------
class
LogSession
;
class
LogAgregator
;
...
...
@@ -120,6 +121,7 @@ class LogServer:
static
std
::
string
help_print
(
const
std
::
string
&
prefix
);
std
::
string
getShortInfo
();
nlohmann
::
json
httpGetShortInfo
();
protected
:
LogServer
();
...
...
include/LogSession.h
View file @
010be9bd
...
...
@@ -27,6 +27,7 @@
#include "UTCPCore.h"
#include "UTCPStream.h"
#include "LogAgregator.h"
#include "json.hpp"
// -------------------------------------------------------------------------
/*! Реализация "сессии" для клиентов LogServer. */
class
LogSession
...
...
@@ -76,6 +77,7 @@ class LogSession
bool
isAcive
()
const
noexcept
;
std
::
string
getShortInfo
()
noexcept
;
nlohmann
::
json
httpGetShortInfo
();
std
::
string
name
()
const
noexcept
;
...
...
src/Log/LogServer.cc
View file @
010be9bd
...
...
@@ -343,6 +343,25 @@ string LogServer::getShortInfo()
return
std
::
move
(
inf
.
str
());
}
// -----------------------------------------------------------------------------
nlohmann
::
json
LogServer
::
httpGetShortInfo
()
{
nlohmann
::
json
jdata
;
jdata
[
"name"
]
=
myname
;
jdata
[
"host"
]
=
addr
;
jdata
[
"port"
]
=
port
;
jdata
[
"sessMaxCount"
]
=
sessMaxCount
;
{
uniset_rwmutex_rlock
l
(
mutSList
);
auto
&
jsess
=
jdata
[
"sessions"
];
for
(
const
auto
&
s
:
slist
)
jsess
.
push_back
(
s
->
httpGetShortInfo
());
}
return
std
::
move
(
jdata
);
}
// -----------------------------------------------------------------------------
void
LogServer
::
saveDefaultLogLevels
(
const
std
::
string
&
logname
)
{
if
(
mylog
.
is_info
()
)
...
...
src/Log/LogSession.cc
View file @
010be9bd
...
...
@@ -674,6 +674,29 @@ string LogSession::getShortInfo() noexcept
return
std
::
move
(
inf
.
str
());
}
// ---------------------------------------------------------------------
nlohmann
::
json
LogSession
::
httpGetShortInfo
()
{
nlohmann
::
json
jret
;
size_t
sz
=
0
;
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
logbuf_mutex
);
sz
=
logbuf
.
size
();
}
auto
&
jdata
=
jret
[
caddr
];
jdata
[
"client"
]
=
caddr
;
jdata
[
"maxbufsize"
]
=
maxRecordsNum
;
jdata
[
"bufsize"
]
=
sz
;
jdata
[
"maxCount"
]
=
maxCount
;
jdata
[
"minSizeMsg"
]
=
minSizeMsg
;
jdata
[
"maxSizeMsg"
]
=
maxSizeMsg
;
jdata
[
"numLostMsg"
]
=
numLostMsg
;
return
std
::
move
(
jret
);
}
// ---------------------------------------------------------------------
string
LogSession
::
name
()
const
noexcept
{
return
caddr
;
...
...
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