Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
f7ebb47d
Commit
f7ebb47d
authored
12 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
[logging] move nested class method defs out-of-line
parent
2b4fec7b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/stuff/common/logstreams.hh
+45
-38
45 additions, 38 deletions
dune/stuff/common/logstreams.hh
with
45 additions
and
38 deletions
dune/stuff/common/logstreams.hh
+
45
−
38
View file @
f7ebb47d
...
...
@@ -74,21 +74,8 @@ public:
}
// Resume
protected
:
virtual
std
::
streamsize
xsputn
(
const
char_type
*
s
,
std
::
streamsize
count
)
{
if
(
enabled
())
return
BaseType
::
xsputn
(
s
,
count
);
// pretend everything was written
return
std
::
streamsize
(
count
);
}
virtual
int_type
overflow
(
int_type
ch
=
traits_type
::
eof
())
{
if
(
enabled
())
return
BaseType
::
overflow
(
ch
);
// anything not equal to traits::eof is considered a success
return
traits_type
::
eof
()
+
1
;
}
virtual
std
::
streamsize
xsputn
(
const
char_type
*
s
,
std
::
streamsize
count
);
virtual
int_type
overflow
(
int_type
ch
=
traits_type
::
eof
());
private
:
inline
bool
enabled
()
const
...
...
@@ -105,6 +92,21 @@ private:
PriorityType
suspend_priority_
;
};
std
::
streamsize
SuspendableStrBuffer
::
xsputn
(
const
char_type
*
s
,
std
::
streamsize
count
)
{
if
(
enabled
())
return
BaseType
::
xsputn
(
s
,
count
);
// pretend everything was written
return
std
::
streamsize
(
count
);
}
SuspendableStrBuffer
::
int_type
SuspendableStrBuffer
::
overflow
(
SuspendableStrBuffer
::
int_type
ch
)
{
if
(
enabled
())
return
BaseType
::
overflow
(
ch
);
// anything not equal to traits::eof is considered a success
return
traits_type
::
eof
()
+
1
;
}
class
LogStream
:
public
std
::
basic_ostream
<
char
,
std
::
char_traits
<
char
>>
{
...
...
@@ -136,12 +138,7 @@ public:
}
//! dump buffer into file/stream and clear it
virtual
LogStream
&
flush
()
{
assert
(
buffer_
);
buffer_
->
pubsync
();
return
*
this
;
}
virtual
LogStream
&
flush
();
/** \brief forwards suspend to buffer
* the suspend_priority_ mechanism provides a way to silence streams from 'higher' modules
...
...
@@ -151,7 +148,7 @@ public:
{
assert
(
buffer_
);
buffer_
->
suspend
(
priority
);
}
// Suspend
}
/** \brief start accepting input into the buffer again
* no-op if not suspended
...
...
@@ -164,9 +161,15 @@ public:
private
:
SuspendableStrBuffer
*
buffer_
;
};
// LogStream
LogStream
&
LogStream
::
flush
()
{
assert
(
buffer_
);
buffer_
->
pubsync
();
return
*
this
;
}
//! ostream compatible class wrapping file and console output
class
FileLogStream
:
public
LogStream
{
...
...
@@ -184,16 +187,7 @@ private:
std
::
ofstream
&
logfile_
;
protected
:
virtual
int
sync
()
{
// flush buffer into stream
std
::
cout
<<
str
();
std
::
cout
.
flush
();
logfile_
<<
str
();
logfile_
.
flush
();
str
(
""
);
return
0
;
}
virtual
int
sync
();
};
public
:
...
...
@@ -208,6 +202,17 @@ private:
FileBuffer
logBuffer_
;
};
// class FileLogStream
int
FileLogStream
::
FileBuffer
::
sync
()
{
// flush buffer into stream
std
::
cout
<<
str
();
std
::
cout
.
flush
();
logfile_
<<
str
();
logfile_
.
flush
();
str
(
""
);
return
0
;
}
//! /dev/null
class
EmptyLogStream
:
public
LogStream
{
...
...
@@ -221,11 +226,7 @@ private:
}
protected
:
virtual
int
sync
()
{
str
(
""
);
return
0
;
}
virtual
int
sync
();
};
public
:
...
...
@@ -240,6 +241,12 @@ private:
EmptyBuffer
logBuffer_
;
};
// class EmptyLogStream
int
EmptyLogStream
::
EmptyBuffer
::
sync
()
{
str
(
""
);
return
0
;
}
namespace
{
int
dev_null_logflag
;
EmptyLogStream
dev_null
(
dev_null_logflag
);
...
...
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