Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
093b1b47
Commit
093b1b47
authored
10 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
Log: Silence errorstream during unittests
parent
10e0cf8b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/log.cpp
+18
-0
18 additions, 0 deletions
src/log.cpp
src/log.h
+8
-1
8 additions, 1 deletion
src/log.h
src/test.cpp
+4
-0
4 additions, 0 deletions
src/test.cpp
with
30 additions
and
1 deletion
src/log.cpp
+
18
−
0
View file @
093b1b47
...
...
@@ -60,6 +60,21 @@ void log_remove_output(ILogOutput *out)
}
}
void
log_set_lev_silence
(
enum
LogMessageLevel
lev
,
bool
silence
)
{
log_threadnamemutex
.
Lock
();
for
(
std
::
list
<
ILogOutput
*>::
iterator
it
=
log_outputs
[
lev
].
begin
();
it
!=
log_outputs
[
lev
].
end
();
++
it
)
{
ILogOutput
*
out
=
*
it
;
out
->
silence
=
silence
;
}
log_threadnamemutex
.
Unlock
();
}
void
log_register_thread
(
const
std
::
string
&
name
)
{
threadid_t
id
=
get_current_thread_id
();
...
...
@@ -107,6 +122,9 @@ void log_printline(enum LogMessageLevel lev, const std::string &text)
for
(
std
::
list
<
ILogOutput
*>::
iterator
i
=
log_outputs
[
lev
].
begin
();
i
!=
log_outputs
[
lev
].
end
();
i
++
){
ILogOutput
*
out
=
*
i
;
if
(
out
->
silence
)
continue
;
out
->
printLog
(
os
.
str
());
out
->
printLog
(
os
.
str
(),
lev
);
out
->
printLog
(
lev
,
text
);
...
...
This diff is collapsed.
Click to expand it.
src/log.h
+
8
−
1
View file @
093b1b47
...
...
@@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/*
Use this for logging everything.
If you need to explicitly print something, use dstream or cout or cerr.
*/
...
...
@@ -39,18 +39,25 @@ enum LogMessageLevel {
class
ILogOutput
{
public:
ILogOutput
()
:
silence
(
false
)
{}
/* line: Full line with timestamp, level and thread */
virtual
void
printLog
(
const
std
::
string
&
line
){};
/* line: Full line with timestamp, level and thread */
virtual
void
printLog
(
const
std
::
string
&
line
,
enum
LogMessageLevel
lev
){};
/* line: Only actual printed text */
virtual
void
printLog
(
enum
LogMessageLevel
lev
,
const
std
::
string
&
line
){};
bool
silence
;
};
void
log_add_output
(
ILogOutput
*
out
,
enum
LogMessageLevel
lev
);
void
log_add_output_maxlev
(
ILogOutput
*
out
,
enum
LogMessageLevel
lev
);
void
log_add_output_all_levs
(
ILogOutput
*
out
);
void
log_remove_output
(
ILogOutput
*
out
);
void
log_set_lev_silence
(
enum
LogMessageLevel
lev
,
bool
silence
);
void
log_register_thread
(
const
std
::
string
&
name
);
void
log_deregister_thread
();
...
...
This diff is collapsed.
Click to expand it.
src/test.cpp
+
4
−
0
View file @
093b1b47
...
...
@@ -2177,6 +2177,8 @@ void run_tests()
IWritableNodeDefManager
*
ndef
=
createNodeDefManager
();
define_some_nodes
(
idef
,
ndef
);
log_set_lev_silence
(
LMT_ERROR
,
true
);
infostream
<<
"run_tests() started"
<<
std
::
endl
;
TEST
(
TestUtilities
);
TEST
(
TestPath
);
...
...
@@ -2198,6 +2200,8 @@ void run_tests()
dout_con
<<
"=== END RUNNING UNIT TESTS FOR CONNECTION ==="
<<
std
::
endl
;
}
log_set_lev_silence
(
LMT_ERROR
,
false
);
delete
idef
;
delete
ndef
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment