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
6519cced
Commit
6519cced
authored
Nov 27, 2021
by
Pavel Vainerman
Committed by
Pavel Vainerman
Nov 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[log]: supported "localtime" (--log-show-localtime)
parent
f52085f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
DebugStream.h
include/DebugStream.h
+7
-0
Configuration.cc
src/Core/Configuration.cc
+10
-1
DebugStream.cc
src/Log/DebugStream.cc
+12
-3
No files found.
include/DebugStream.h
View file @
6519cced
...
...
@@ -175,6 +175,12 @@ class DebugStream : public std::ostream
show_datetime
=
s
;
}
// false = UTC (by default)
inline
void
showLocalTime
(
bool
s
)
noexcept
{
show_localtime
=
s
;
}
inline
void
showMilliseconds
(
bool
s
)
noexcept
{
show_msec
=
s
;
...
...
@@ -296,6 +302,7 @@ class DebugStream : public std::ostream
bool
show_logtype
=
{
true
};
bool
show_msec
=
{
false
};
bool
show_usec
=
{
false
};
bool
show_localtime
=
{
false
};
std
::
string
fname
=
{
""
};
StreamEvent_Signal
s_stream
;
...
...
src/Core/Configuration.cc
View file @
6519cced
...
...
@@ -65,6 +65,7 @@ std::string uniset::Configuration::help()
print_help
(
os
,
25
,
"--ulog-del-levels"
,
"удалить уровень вывода логов
\n
"
);
print_help
(
os
,
25
,
"--ulog-show-microseconds"
,
"Выводить время с микросекундами
\n
"
);
print_help
(
os
,
25
,
"--ulog-show-milliseconds"
,
"Выводить время с миллисекундами
\n
"
);
print_help
(
os
,
25
,
"--ulog-show-localtime"
,
"Выводить локальное время. По умолчанию UTC.
\n
"
);
print_help
(
os
,
25
,
"--ulog-no-debug"
,
"отключение логов
\n
"
);
print_help
(
os
,
25
,
"--ulog-logfile"
,
"перенаправление лога в файл
\n
"
);
print_help
(
os
,
25
,
"--ulog-levels N"
,
"уровень 'говорливости' логов"
);
...
...
@@ -913,7 +914,7 @@ namespace uniset
if
(
!
node
)
{
ucrit
<<
"(Configuration): <nodes> section not found!"
<<
endl
;
throw
uniset
::
SystemError
(
"(Config
i
uration): <nodes> section not found"
);
throw
uniset
::
SystemError
(
"(Configuration): <nodes> section not found"
);
}
UniXML
::
iterator
it
(
node
);
...
...
@@ -1067,6 +1068,9 @@ namespace uniset
deb
->
addLevel
(
Debug
::
NONE
);
debug_file
=
getProp
(
dnode
,
"file"
);
if
(
getPIntProp
(
dnode
,
"showLocalTime"
,
0
)
!=
0
)
deb
->
showLocalTime
(
true
);
}
// теперь смотрим командную строку
...
...
@@ -1076,6 +1080,7 @@ namespace uniset
const
string
show_msec
(
"--"
+
debname
+
"-show-milliseconds"
);
const
string
show_usec
(
"--"
+
debname
+
"-show-microseconds"
);
const
string
verb_level
(
"--"
+
debname
+
"-verbosity"
);
const
string
show_localtime
(
"--"
+
debname
+
"-show-localtime"
);
// смотрим командную строку
for
(
int
i
=
1
;
i
<
(
_argc
-
1
);
i
++
)
...
...
@@ -1104,6 +1109,10 @@ namespace uniset
{
deb
->
verbose
(
uniset
::
uni_atoi
(
_argv
[
i
+
1
]));
}
else
if
(
show_localtime
==
_argv
[
i
]
)
{
deb
->
showLocalTime
(
uniset
::
uni_atoi
(
_argv
[
i
+
1
]));
}
}
if
(
!
debug_file
.
empty
()
)
...
...
src/Log/DebugStream.cc
View file @
6519cced
...
...
@@ -211,7 +211,10 @@ std::ostream& DebugStream::printDate(Debug::type t, char brk) noexcept
std
::
time_t
tv
=
std
::
chrono
::
system_clock
::
to_time_t
(
std
::
chrono
::
system_clock
::
now
());
std
::
tm
tms
;
gmtime_r
(
&
tv
,
&
tms
);
if
(
show_localtime
)
localtime_r
(
&
tv
,
&
tms
);
else
gmtime_r
(
&
tv
,
&
tms
);
#if __GNUC__ >= 5
std
::
ostringstream
fmt
;
...
...
@@ -235,7 +238,10 @@ std::ostream& DebugStream::printTime(Debug::type t, char brk) noexcept
timespec
tv
=
uniset
::
now_to_timespec
();
// gettimeofday(tv,0);
std
::
tm
tms
;
gmtime_r
(
&
tv
.
tv_sec
,
&
tms
);
if
(
show_localtime
)
localtime_r
(
&
tv
.
tv_sec
,
&
tms
);
else
gmtime_r
(
&
tv
.
tv_sec
,
&
tms
);
#if __GNUC__ >= 5
std
::
ostringstream
fmt
;
...
...
@@ -266,7 +272,10 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept
timespec
tv
=
uniset
::
now_to_timespec
();
// gettimeofday(tv,0);
std
::
tm
tms
;
gmtime_r
(
&
tv
.
tv_sec
,
&
tms
);
if
(
show_localtime
)
localtime_r
(
&
tv
.
tv_sec
,
&
tms
);
else
gmtime_r
(
&
tv
.
tv_sec
,
&
tms
);
#if __GNUC__ >= 5
*
this
<<
std
::
put_time
(
&
tms
,
"%Od/%Om/%Y %OH:%OM:%OS"
);
...
...
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