Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
06eeabaa
Commit
06eeabaa
authored
Nov 20, 2009
by
Sebastian Eichelbaum
Browse files
[CHANGE] - now different formats for log files and console logging used
parent
a6ac6c9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
src/common/WLogger.cpp
src/common/WLogger.cpp
+17
-2
src/common/WLogger.h
src/common/WLogger.h
+19
-0
No files found.
src/common/WLogger.cpp
View file @
06eeabaa
...
...
@@ -45,7 +45,8 @@ WLogger::WLogger( std::string fileName, LogLevel level ):
m_LogFileName
(
fileName
),
m_QueueMutex
(),
m_colored
(
true
),
m_defaultFormat
(
"*%l [%s] %m
\n
"
)
m_defaultFormat
(
"*%l [%s] %m
\n
"
),
m_defaultFileFormat
(
"[%t] *%l*%s* %m
\n
"
)
{
logger
=
this
;
...
...
@@ -139,7 +140,11 @@ void WLogger::processQueue()
// for atomic file usage.
boost
::
filesystem
::
path
p
(
"walnut.log"
);
boost
::
filesystem
::
ofstream
ofs
(
p
,
boost
::
filesystem
::
ofstream
::
app
);
ofs
<<
entry
.
getLogString
(
m_defaultFormat
);
bool
tmp
=
entry
.
isColored
();
entry
.
setColored
(
false
);
ofs
<<
entry
.
getLogString
(
m_defaultFileFormat
);
entry
.
setColored
(
tmp
);
}
}
}
...
...
@@ -183,3 +188,13 @@ std::string WLogger::getDefaultFormat()
return
m_defaultFormat
;
}
void
WLogger
::
setDefaultFileFormat
(
std
::
string
format
)
{
m_defaultFileFormat
=
format
;
}
std
::
string
WLogger
::
getDefaultFileFormat
()
{
return
m_defaultFileFormat
;
}
src/common/WLogger.h
View file @
06eeabaa
...
...
@@ -114,6 +114,20 @@ public:
*/
std
::
string
getDefaultFormat
();
/**
* Set the default format used for log entries in log files.
*
* \param format the format string. See WLogEntry for details.
*/
void
setDefaultFileFormat
(
std
::
string
format
);
/**
* Gets the default format used for log entries in log files.
*
* \return format string. See WLogEntry for details.
*/
std
::
string
getDefaultFileFormat
();
/**
* Appends a log message to the logging queue.
*/
...
...
@@ -188,6 +202,11 @@ private:
* The default format used for new log entries.
*/
std
::
string
m_defaultFormat
;
/**
* The default format used for new log entries in files.
*/
std
::
string
m_defaultFileFormat
;
};
#endif // WLOGGER_H
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