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
6e06e4a5
Commit
6e06e4a5
authored
May 25, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogServer): добавил команду вывода списка подключённых (контролируемых) логов,
edit todo, make style
parent
1f3682ef
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
197 additions
and
115 deletions
+197
-115
TODO
TODO
+0
-1
log.cc
Utilities/ULog/log.cc
+9
-1
logserver.cc
Utilities/ULog/logserver.cc
+2
-0
RRDServer.cc
extensions/RRDServer/RRDServer.cc
+1
-1
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+2
-2
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+2
-2
UObject_SK.h
extensions/include/UObject_SK.h
+55
-49
UObject_SK.cc
extensions/lib/UObject_SK.cc
+69
-56
LogAgregator.h
include/LogAgregator.h
+3
-0
LogServerTypes.h
include/LogServerTypes.h
+2
-1
ObjectIndex.h
include/ObjectIndex.h
+1
-1
UniXML.h
include/UniXML.h
+1
-1
LogAgregator.cc
src/Log/LogAgregator.cc
+10
-0
LogReader.cc
src/Log/LogReader.cc
+11
-0
LogSession.cc
src/Log/LogSession.cc
+29
-0
No files found.
TODO
View file @
6e06e4a5
...
...
@@ -45,7 +45,6 @@ Version 2.0
uniset-codegen: добавить ключ --gen-sensor-name для генерирования name_Item.. (чтобы можно было в логах использовать текстовые названия)
- перевести PassiveTimer на использование crono:: (c++11)
- LogServer: добавил команду -l для вывода списка "доступных"(управляемых) логов
SQL:
====
...
...
Utilities/ULog/log.cc
View file @
6e06e4a5
...
...
@@ -21,6 +21,7 @@ static struct option longopts[] =
{
"set"
,
required_argument
,
0
,
's'
},
{
"off"
,
required_argument
,
0
,
'o'
},
{
"on"
,
required_argument
,
0
,
'n'
},
{
"list"
,
no_argument
,
0
,
'm'
},
{
"rotate"
,
required_argument
,
0
,
'r'
},
{
"logname"
,
required_argument
,
0
,
'l'
},
{
"command-only"
,
no_argument
,
0
,
'b'
},
...
...
@@ -49,10 +50,13 @@ static void print_help()
printf
(
"--off, -o - Off the write log file (if enabled).
\n
"
);
printf
(
"--on, -n - On the write log file (if before disabled).
\n
"
);
printf
(
"--rotate, -r - rotate log file.
\n
"
);
printf
(
"--list, -m - List of managed logs.
\n
"
);
}
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
std
::
ios
::
sync_with_stdio
(
false
);
int
optindex
=
0
;
int
opt
=
0
;
int
verb
=
0
;
...
...
@@ -69,7 +73,7 @@ int main( int argc, char** argv )
try
{
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hva:p:i:d:s:l:onrbx:w:"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hv
m
a:p:i:d:s:l:onrbx:w:"
,
longopts
,
&
optindex
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -98,6 +102,10 @@ int main( int argc, char** argv )
}
break
;
case
'm'
:
cmd
=
LogServerTypes
::
cmdList
;
break
;
case
'o'
:
cmd
=
LogServerTypes
::
cmdOffLogFile
;
break
;
...
...
Utilities/ULog/logserver.cc
View file @
6e06e4a5
...
...
@@ -34,6 +34,8 @@ static void print_help()
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
std
::
ios
::
sync_with_stdio
(
false
);
int
optindex
=
0
;
int
opt
=
0
;
int
verb
=
0
;
...
...
extensions/RRDServer/RRDServer.cc
View file @
6e06e4a5
...
...
@@ -13,7 +13,7 @@ using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
RRDServer
::
RRDServer
(
UniSetTypes
::
ObjectId
objId
,
xmlNode
*
cnode
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
,
const
string
&
prefix
)
:
UObject_SK
(
objId
,
cnode
,
string
(
prefix
+
"-"
)),
UObject_SK
(
objId
,
cnode
,
string
(
prefix
+
"-"
)),
prefix
(
prefix
)
{
auto
conf
=
uniset_conf
();
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
6e06e4a5
...
...
@@ -541,10 +541,10 @@ bool UNetReceiver::recv()
// -----------------------------------------------------------------------------
void
UNetReceiver
::
initIterators
()
{
for
(
auto
&&
it
:
d_icache
)
for
(
auto
&&
it
:
d_icache
)
shm
->
initIterator
(
it
.
ioit
);
for
(
auto
&&
it
:
a_icache
)
for
(
auto
&&
it
:
a_icache
)
shm
->
initIterator
(
it
.
ioit
);
}
// -----------------------------------------------------------------------------
...
...
extensions/UNetUDP/UNetSender.cc
View file @
6e06e4a5
...
...
@@ -357,13 +357,13 @@ std::ostream& operator<<( std::ostream& os, UNetSender::UItem& p )
// -----------------------------------------------------------------------------
void
UNetSender
::
initIterators
()
{
for
(
auto
&&
it
:
dlist
)
for
(
auto
&&
it
:
dlist
)
shm
->
initIterator
(
it
.
ioit
);
}
// -----------------------------------------------------------------------------
void
UNetSender
::
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{
for
(
auto
&&
it
:
dlist
)
for
(
auto
&&
it
:
dlist
)
shm
->
askSensor
(
it
.
id
,
cmd
);
}
// -----------------------------------------------------------------------------
extensions/include/UObject_SK.h
View file @
6e06e4a5
...
...
@@ -28,7 +28,7 @@ class UObject_SK:
public
LT_Object
{
public
:
UObject_SK
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
node
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
node
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
();
virtual
~
UObject_SK
();
...
...
@@ -44,45 +44,45 @@ class UObject_SK:
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
);
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( mylog->debugging(Debug::INFO) ) mylog->info()
#endif
#ifndef mywarn
#define mywarn if( mylog->debugging(Debug::WARN) ) mylog->warn()
#endif
#ifndef mycrit
#define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->crit()
#endif
#ifndef mylog1
#define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->level1()
#endif
#ifndef mylog2
#define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->level2()
#endif
#ifndef mylog3
#define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->level3()
#endif
#ifndef mylog4
#define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->level4()
#endif
#ifndef mylog5
#define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->level5()
#endif
#ifndef mylog6
#define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->level6()
#endif
#ifndef mylog7
#define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->level7()
#endif
#ifndef mylog8
#define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->level8()
#endif
#ifndef mylog9
#define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->level9()
#endif
#ifndef mylogany
#define mylogany mylog->any()
#endif
#ifndef myinfo
#define myinfo if( mylog->debugging(Debug::INFO) ) mylog->info()
#endif
#ifndef mywarn
#define mywarn if( mylog->debugging(Debug::WARN) ) mylog->warn()
#endif
#ifndef mycrit
#define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->crit()
#endif
#ifndef mylog1
#define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->level1()
#endif
#ifndef mylog2
#define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->level2()
#endif
#ifndef mylog3
#define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->level3()
#endif
#ifndef mylog4
#define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->level4()
#endif
#ifndef mylog5
#define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->level5()
#endif
#ifndef mylog6
#define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->level6()
#endif
#ifndef mylog7
#define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->level7()
#endif
#ifndef mylog8
#define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->level8()
#endif
#ifndef mylog9
#define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->level9()
#endif
#ifndef mylogany
#define mylogany mylog->any()
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
...
...
@@ -99,13 +99,13 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*!< Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
// ------------------------------------------------------------
...
...
@@ -133,10 +133,10 @@ class UObject_SK:
virtual
void
callback
()
override
;
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
)
override
;
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
){};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
){}
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
{}
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
{};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{}
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
{}
virtual
void
sigterm
(
int
signo
)
override
;
virtual
bool
activateObject
()
override
;
virtual
void
testMode
(
bool
state
);
...
...
@@ -156,7 +156,7 @@ class UObject_SK:
int
resetMsgTime
;
// Выполнение очередного шага программы
virtual
void
step
(){}
virtual
void
step
()
{}
int
sleep_msec
;
/*!< пауза между итерациями */
bool
active
;
...
...
@@ -171,9 +171,15 @@ class UObject_SK:
xmlNode
*
confnode
;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int
getIntProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
int
getIntProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
int
smReadyTimeout
;
/*!< время ожидания готовности SM */
std
::
atomic_bool
activated
;
...
...
extensions/lib/UObject_SK.cc
View file @
6e06e4a5
This diff is collapsed.
Click to expand it.
include/LogAgregator.h
View file @
6e06e4a5
...
...
@@ -3,6 +3,7 @@
// -------------------------------------------------------------------------
#include <string>
#include <memory>
#include <list>
#include <unordered_map>
#include "DebugStream.h"
#include "LogServerTypes.h"
...
...
@@ -39,6 +40,8 @@ class LogAgregator:
std
::
shared_ptr
<
DebugStream
>
getLog
(
const
std
::
string
&
logname
);
LogInfo
getLogInfo
(
const
std
::
string
&
logname
);
std
::
list
<
std
::
shared_ptr
<
DebugStream
>>
getLogList
();
protected
:
void
logOnEvent
(
const
std
::
string
&
s
);
...
...
include/LogServerTypes.h
View file @
6e06e4a5
...
...
@@ -16,7 +16,8 @@ namespace LogServerTypes
cmdDelLevel
,
/*!< удалить уровень вывода */
cmdRotate
,
/*!< пересоздать файл с логами */
cmdOffLogFile
,
/*!< отключить запись файла логов (если включена) */
cmdOnLogFile
/*!< включить запись файла логов (если была отключена) */
cmdOnLogFile
,
/*!< включить запись файла логов (если была отключена) */
cmdList
/*!< вывести список контролируемых логов */
// cmdSetLogFile
};
...
...
include/ObjectIndex.h
View file @
6e06e4a5
...
...
@@ -66,7 +66,7 @@ namespace UniSetTypes
void
initLocalNode
(
const
UniSetTypes
::
ObjectId
nodeid
);
protected
:
std
::
string
nmLocalNode
=
{
""
};
// поле для оптимизации получения LocalNode
std
::
string
nmLocalNode
=
{
""
};
// поле для оптимизации получения LocalNode
private
:
...
...
include/UniXML.h
View file @
6e06e4a5
...
...
@@ -44,7 +44,7 @@ class UniXML_iterator:
UniXML_iterator
(
xmlNode
*
node
)
:
curNode
(
node
)
{}
UniXML_iterator
()
:
curNode
(
0
)
{}
UniXML_iterator
()
:
curNode
(
0
)
{}
std
::
string
getProp2
(
const
std
::
string
&
name
,
const
std
::
string
&
defval
=
""
);
std
::
string
getProp
(
const
std
::
string
&
name
);
...
...
src/Log/LogAgregator.cc
View file @
6e06e4a5
...
...
@@ -108,3 +108,13 @@ LogAgregator::LogInfo LogAgregator::getLogInfo( const std::string& logname )
return
LogInfo
();
}
// -------------------------------------------------------------------------
std
::
list
<
std
::
shared_ptr
<
DebugStream
>>
LogAgregator
::
getLogList
()
{
std
::
list
<
std
::
shared_ptr
<
DebugStream
>
>
l
;
for
(
auto
&&
i
:
lmap
)
l
.
push_back
(
i
.
second
.
log
);
return
std
::
move
(
l
);
}
// -------------------------------------------------------------------------
src/Log/LogReader.cc
View file @
6e06e4a5
...
...
@@ -150,6 +150,8 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
while
(
n
>
0
)
{
try
{
if
(
!
isConnection
()
)
connect
(
_addr
,
_port
,
reconDelay
);
...
...
@@ -209,6 +211,15 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
rlog
.
warn
()
<<
"(LogReader): ...connection timeout..."
<<
endl
;
send_ok
=
false
;
// ??!! делать ли?
disconnect
();
}
catch
(
const
ost
::
SockException
&
e
)
{
cerr
<<
"(LogReader): "
<<
e
.
getString
()
<<
" ("
<<
_addr
<<
")"
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
cerr
<<
"(LogReader): "
<<
ex
.
what
()
<<
endl
;
}
if
(
readcount
>
0
)
n
--
;
...
...
src/Log/LogSession.cc
View file @
6e06e4a5
...
...
@@ -168,6 +168,35 @@ void LogSession::run()
break
;
case
LogServerTypes
:
:
cmdList
:
{
if
(
isPending
(
Socket
::
pendingOutput
,
cmdTimeout
)
)
{
ostringstream
s
;
s
<<
"List of managed logs:"
<<
endl
;
s
<<
"====================="
<<
endl
;
auto
lag
=
dynamic_pointer_cast
<
LogAgregator
>
(
log
);
if
(
!
lag
)
{
s
<<
log
->
getLogName
()
<<
endl
;
}
else
{
auto
lst
=
lag
->
getLogList
();
for
(
const
auto
&
i
:
lst
)
s
<<
i
->
getLogName
()
<<
endl
;
}
s
<<
"====================="
<<
endl
;
*
tcp
()
<<
s
.
str
();
tcp
()
->
sync
();
}
}
break
;
case
LogServerTypes
:
:
cmdOffLogFile
:
{
if
(
!
logfile
.
empty
()
)
...
...
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