Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
ofxImGui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wt
ofxImGui
Commits
9f4e3b74
Commit
9f4e3b74
authored
Dec 02, 2019
by
w4t
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
when using ofxImGuiLoggerChannel, optionally log to console as well
parent
02620f19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
ofxImGuiLoggerChannel.cpp
src/ofxImGuiLoggerChannel.cpp
+8
-1
ofxImGuiLoggerChannel.h
src/ofxImGuiLoggerChannel.h
+5
-0
No files found.
src/ofxImGuiLoggerChannel.cpp
View file @
9f4e3b74
#include "ofxImGuiLoggerChannel.h"
//--------------------------------------------------------------
ofxImGui
::
LoggerChannel
::
LoggerChannel
(){
consoleChannel
=
new
ofConsoleLoggerChannel
();
}
//--------------------------------------------------------------
ImGuiTextBuffer
&
ofxImGui
::
LoggerChannel
::
getBuffer
(){
static
ImGuiTextBuffer
sLogBuffer
;
// static log buffer for logger channel
return
sLogBuffer
;
...
...
@@ -10,8 +13,10 @@ ImGuiTextBuffer& ofxImGui::LoggerChannel::getBuffer(){
//--------------------------------------------------------------
void
ofxImGui
::
LoggerChannel
::
log
(
ofLogLevel
level
,
const
std
::
string
&
module
,
const
std
::
string
&
message
){
getBuffer
().
appendf
(
"[%s] %s: %s
\n
"
,
ofGetLogLevelName
(
level
,
true
).
c_str
(),
module
.
c_str
(),
message
.
c_str
()
);
if
(
logToConsole
)
consoleChannel
->
log
(
level
,
module
,
message
);
}
//--------------------------------------------------------------
void
ofxImGui
::
LoggerChannel
::
log
(
ofLogLevel
level
,
const
std
::
string
&
module
,
const
char
*
format
,
...
){
va_list
args
;
va_start
(
args
,
format
);
...
...
@@ -19,9 +24,11 @@ void ofxImGui::LoggerChannel::log( ofLogLevel level, const std::string & module,
va_end
(
args
);
}
//--------------------------------------------------------------
void
ofxImGui
::
LoggerChannel
::
log
(
ofLogLevel
level
,
const
std
::
string
&
module
,
const
char
*
format
,
va_list
args
){
getBuffer
().
appendf
(
"[%s] %s: "
,
ofGetLogLevelName
(
level
,
true
).
c_str
(),
module
.
c_str
()
);
getBuffer
().
appendfv
(
format
,
args
);
if
(
logToConsole
)
consoleChannel
->
log
(
level
,
module
,
format
,
args
);
}
...
...
src/ofxImGuiLoggerChannel.h
View file @
9f4e3b74
...
...
@@ -9,14 +9,19 @@ namespace ofxImGui {
class
LoggerChannel
:
public
ofBaseLoggerChannel
{
public:
LoggerChannel
();
static
ImGuiTextBuffer
&
getBuffer
();
void
setLogToConsole
(
bool
log
){
logToConsole
=
log
;}
/// \brief Destroy the console logger channel.
virtual
~
LoggerChannel
(){};
void
log
(
ofLogLevel
level
,
const
std
::
string
&
module
,
const
std
::
string
&
message
);
void
log
(
ofLogLevel
level
,
const
std
::
string
&
module
,
const
char
*
format
,
...
)
OF_PRINTF_ATTR
(
4
,
5
);
void
log
(
ofLogLevel
level
,
const
std
::
string
&
module
,
const
char
*
format
,
va_list
args
);
bool
logToConsole
=
true
;
ofConsoleLoggerChannel
*
consoleChannel
=
nullptr
;
};
}
// end namespace ofxImGui
...
...
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