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
1f406d70
Commit
1f406d70
authored
Jun 02, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogServer): работа над форматом вывода списка логов
parent
7e0114b5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
45 deletions
+97
-45
logserver.cc
Utilities/ULog/logserver.cc
+16
-5
sm_perf_test.cc
extensions/tests/sm_perf_test.cc
+1
-1
LogAgregator.h
include/LogAgregator.h
+3
-0
LogAgregator.cc
src/Log/LogAgregator.cc
+29
-6
LogSession.cc
src/Log/LogSession.cc
+48
-33
No files found.
Utilities/ULog/logserver.cc
View file @
1f406d70
// --------------------------------------------------------------------------
#include <string>
#include <iomanip>
#include <getopt.h>
#include "Debug.h"
#include "UniSetTypes.h"
...
...
@@ -132,15 +133,25 @@ int main( int argc, char** argv )
auto
dlog6
=
la3
->
create
(
"dlog6"
);
la
->
add
(
la3
);
for
(
int
i
=
0
;
i
<
15
;
i
++
)
{
ostringstream
s
;
s
<<
i
;
auto
l
=
make_shared
<
LogAgregator
>
(
"LongLongNameWith"
+
s
.
str
());
l
->
create
(
"dlog1"
);
l
->
create
(
"shortdlog2"
);
l
->
create
(
"longnamedlog3"
);
la
->
add
(
l
);
}
#if 0
cout << la << endl;
cout << "************ " << endl;
auto lst = la->getLogList();
for( const auto& l : lst )
cout << l.name << endl;
la->printLogList(cout);
return 0;
#endif
...
...
extensions/tests/sm_perf_test.cc
View file @
1f406d70
...
...
@@ -51,7 +51,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
while
(
num
--
)
{
int
v
=
shm
->
getValue
(
sid
);
shm
->
getValue
(
sid
);
}
};
...
...
include/LogAgregator.h
View file @
1f406d70
...
...
@@ -157,6 +157,9 @@ class LogAgregator:
static
std
::
vector
<
std
::
string
>
splitFirst
(
const
std
::
string
&
lname
,
const
std
::
string
s
=
"/"
);
std
::
ostream
&
printLogList
(
std
::
ostream
&
os
,
const
std
::
string
&
regexp_str
=
""
);
static
std
::
ostream
&
printLogList
(
std
::
ostream
&
os
,
std
::
list
<
iLog
>&
lst
);
protected
:
void
logOnEvent
(
const
std
::
string
&
s
);
void
addLog
(
std
::
shared_ptr
<
DebugStream
>
l
,
const
std
::
string
&
lname
);
...
...
src/Log/LogAgregator.cc
View file @
1f406d70
...
...
@@ -143,14 +143,39 @@ std::shared_ptr<DebugStream> LogAgregator::getLog( const std::string& logname )
return
findLog
(
logname
);
}
// -------------------------------------------------------------------------
std
::
ostream
&
LogAgregator
::
printLogList
(
std
::
ostream
&
os
,
const
std
::
string
&
regexp_str
)
{
std
::
list
<
iLog
>
lst
;
if
(
regexp_str
.
empty
()
)
lst
=
getLogList
();
else
lst
=
getLogList
(
regexp_str
);
}
// -------------------------------------------------------------------------
std
::
ostream
&
LogAgregator
::
printLogList
(
std
::
ostream
&
os
,
std
::
list
<
iLog
>&
lst
)
{
std
::
string
::
size_type
max_width
=
1
;
for
(
const
auto
&
l
:
lst
)
max_width
=
std
::
max
(
max_width
,
l
.
name
.
length
()
);
for
(
const
auto
&
l
:
lst
)
os
<<
std
::
left
<<
setw
(
max_width
)
<<
l
.
name
<<
std
::
left
<<
" [ "
<<
Debug
::
str
(
l
.
log
->
level
())
<<
" ]"
<<
endl
;
return
os
;
}
// -------------------------------------------------------------------------
std
::
ostream
&
LogAgregator
::
printTree
(
std
::
ostream
&
os
,
const
std
::
string
&
g_tab
)
{
const
std
::
string
::
size_type
tab_width
=
15
;
ostringstream
s
;
s
<<
" ."
<<
g_tab
;
s
<<
"
."
<<
g_tab
;
string
s_tab
(
s
.
str
());
os
<<
g_tab
<<
getLogName
()
<<
sep
<<
endl
;
// << setw(6) << " " << "[ " << Debug::str(DebugStream::level()) << " ]" << endl;
os
<<
std
::
left
<<
g_tab
<<
getLogName
()
<<
sep
<<
endl
;
// << setw(6) << " " << "[ " << Debug::str(DebugStream::level()) << " ]" << endl;
std
::
list
<
std
::
shared_ptr
<
DebugStream
>>
lst
;
for
(
const
auto
&
l
:
lmap
)
...
...
@@ -166,11 +191,9 @@ std::ostream& LogAgregator::printTree( std::ostream& os, const std::string& g_ta
auto
ag
=
dynamic_pointer_cast
<
LogAgregator
>
(
l
);
if
(
ag
)
{
ag
->
printTree
(
os
,
s_tab
);
}
else
os
<<
s_tab
<<
l
->
getLogName
()
<<
" [ "
<<
Debug
::
str
(
l
->
level
())
<<
" ]"
<<
endl
;
os
<<
s_tab
<<
setw
(
tab_width
)
<<
std
::
right
<<
l
->
getLogName
()
<<
std
::
left
<<
" [ "
<<
Debug
::
str
(
l
->
level
())
<<
" ]"
<<
endl
;
}
return
os
;
...
...
@@ -178,7 +201,7 @@ std::ostream& LogAgregator::printTree( std::ostream& os, const std::string& g_ta
// -------------------------------------------------------------------------
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
LogAgregator
&
la
)
{
la
.
printTree
(
os
,
""
);
la
.
printTree
(
os
,
""
);
return
os
;
}
// -------------------------------------------------------------------------
...
...
src/Log/LogSession.cc
View file @
1f406d70
#include <iostream>
#include <iomanip>
#include <memory>
#include <string>
#include <sstream>
...
...
@@ -112,48 +113,30 @@ void LogSession::run()
std
::
list
<
LogAgregator
::
iLog
>
loglist
;
if
(
!
cmdLogName
.
empty
()
)
if
(
alog
)
// если у нас "агрегатор", то работаем с его списком потоков
{
if
(
alog
)
// если у нас "агрегатор", то работаем с его списком потоков
{
if
(
cmdLogName
==
"ALL"
)
loglist
=
alog
->
getLogList
();
else
loglist
=
alog
->
getLogList
(
cmdLogName
);
}
if
(
cmdLogName
.
empty
()
||
cmdLogName
==
"ALL"
)
loglist
=
alog
->
getLogList
();
else
loglist
=
alog
->
getLogList
(
cmdLogName
);
}
else
{
if
(
cmdLogName
.
empty
()
||
cmdLogName
==
"ALL"
||
log
->
getLogFile
()
==
cmdLogName
)
{
if
(
cmdLogName
==
"ALL"
||
log
->
getLogFile
()
==
cmdLogName
)
{
LogAgregator
::
iLog
llog
(
log
,
log
->
getLogName
());
loglist
.
push_back
(
llog
);
}
LogAgregator
::
iLog
llog
(
log
,
log
->
getLogName
());
loglist
.
push_back
(
llog
);
}
}
// это команда по всем логам..
// если команда "вывести список"
// выводим и завершаем работу
if
(
msg
.
cmd
==
LogServerTypes
::
cmdList
)
{
ostringstream
s
;
s
<<
"List of managed logs:"
<<
endl
;
s
<<
"List of managed logs
(filter='"
<<
cmdLogName
<<
"')
:"
<<
endl
;
s
<<
"====================="
<<
endl
;
if
(
!
alog
)
{
s
<<
log
->
getLogName
()
<<
endl
;
}
else
{
if
(
!
cmdLogName
.
empty
()
)
{
auto
lst
=
alog
->
getLogList
(
cmdLogName
);
for
(
const
auto
&
l
:
lst
)
s
<<
l
.
name
<<
" [ "
<<
Debug
::
str
(
l
.
log
->
level
())
<<
" ]"
<<
endl
;
}
else
s
<<
alog
<<
endl
;
}
LogAgregator
::
printLogList
(
s
,
loglist
);
s
<<
"====================="
<<
endl
<<
endl
;
if
(
isPending
(
Socket
::
pendingOutput
,
cmdTimeout
)
)
...
...
@@ -162,7 +145,7 @@ void LogSession::run()
tcp
()
->
sync
();
}
//
по идее
вывели список и завершили работу..
// вывели список и завершили работу..
cancelled
=
true
;
disconnect
();
return
;
...
...
@@ -218,6 +201,38 @@ void LogSession::run()
break
;
}
}
// Выводим итоговый получившийся список (с учётом выполненных команд)
ostringstream
s
;
if
(
msg
.
cmd
==
LogServerTypes
::
cmdFilterMode
)
{
s
<<
"List of managed logs(filter='"
<<
cmdLogName
<<
"'):"
<<
endl
;
s
<<
"====================="
<<
endl
;
LogAgregator
::
printLogList
(
s
,
loglist
);
s
<<
"====================="
<<
endl
<<
endl
;
}
else
{
s
<<
"List of managed logs:"
<<
endl
;
s
<<
"====================="
<<
endl
;
// выводим полный список
if
(
alog
)
{
auto
lst
=
alog
->
getLogList
();
LogAgregator
::
printLogList
(
s
,
lst
);
}
else
s
<<
log
->
getLogName
()
<<
" ["
<<
Debug
::
str
(
log
->
level
())
<<
" ]"
<<
endl
;
s
<<
"====================="
<<
endl
<<
endl
;
}
if
(
isPending
(
Socket
::
pendingOutput
,
cmdTimeout
)
)
{
*
tcp
()
<<
s
.
str
();
tcp
()
->
sync
();
}
}
}
}
...
...
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