Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
92e5a8ee
Commit
92e5a8ee
authored
Feb 15, 2018
by
Robert Kimball
Committed by
Scott Cyphers
Feb 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move log from nervana to ngraph namespace (#496)
parent
9348da6d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
34 deletions
+34
-34
log.cpp
src/ngraph/log.cpp
+16
-16
log.hpp
src/ngraph/log.hpp
+18
-18
No files found.
src/ngraph/log.cpp
View file @
92e5a8ee
...
...
@@ -26,45 +26,45 @@
using
namespace
std
;
namespace
n
ervana
namespace
n
graph
{
class
thread_starter
;
}
string
n
ervana
::
logger
::
log_path
;
deque
<
string
>
n
ervana
::
logger
::
queue
;
string
n
graph
::
logger
::
log_path
;
deque
<
string
>
n
graph
::
logger
::
queue
;
static
mutex
queue_mutex
;
static
condition_variable
queue_condition
;
static
unique_ptr
<
thread
>
queue_thread
;
static
bool
active
=
false
;
std
::
ostream
&
n
ervana
::
get_nil_stream
()
std
::
ostream
&
n
graph
::
get_nil_stream
()
{
static
std
::
stringstream
nil
;
return
nil
;
}
class
n
ervana
::
thread_starter
class
n
graph
::
thread_starter
{
public
:
thread_starter
()
{
n
ervana
::
logger
::
start
();
}
virtual
~
thread_starter
()
{
n
ervana
::
logger
::
stop
();
}
thread_starter
()
{
n
graph
::
logger
::
start
();
}
virtual
~
thread_starter
()
{
n
graph
::
logger
::
stop
();
}
};
static
n
ervana
::
thread_starter
_starter
;
static
n
graph
::
thread_starter
_starter
;
void
n
ervana
::
logger
::
set_log_path
(
const
string
&
path
)
void
n
graph
::
logger
::
set_log_path
(
const
string
&
path
)
{
log_path
=
path
;
}
void
n
ervana
::
logger
::
start
()
void
n
graph
::
logger
::
start
()
{
active
=
true
;
queue_thread
=
unique_ptr
<
thread
>
(
new
thread
(
&
thread_entry
,
nullptr
));
}
void
n
ervana
::
logger
::
stop
()
void
n
graph
::
logger
::
stop
()
{
{
unique_lock
<
std
::
mutex
>
lk
(
queue_mutex
);
...
...
@@ -74,12 +74,12 @@ void nervana::logger::stop()
queue_thread
->
join
();
}
void
n
ervana
::
logger
::
process_event
(
const
string
&
s
)
void
n
graph
::
logger
::
process_event
(
const
string
&
s
)
{
cout
<<
s
<<
"
\n
"
;
}
void
n
ervana
::
logger
::
thread_entry
(
void
*
param
)
void
n
graph
::
logger
::
thread_entry
(
void
*
param
)
{
unique_lock
<
std
::
mutex
>
lk
(
queue_mutex
);
while
(
active
)
...
...
@@ -93,14 +93,14 @@ void nervana::logger::thread_entry(void* param)
}
}
void
n
ervana
::
logger
::
log_item
(
const
string
&
s
)
void
n
graph
::
logger
::
log_item
(
const
string
&
s
)
{
unique_lock
<
std
::
mutex
>
lk
(
queue_mutex
);
queue
.
push_back
(
s
);
queue_condition
.
notify_one
();
}
n
ervana
::
log_helper
::
log_helper
(
LOG_TYPE
type
,
const
char
*
file
,
int
line
,
const
char
*
func
)
n
graph
::
log_helper
::
log_helper
(
LOG_TYPE
type
,
const
char
*
file
,
int
line
,
const
char
*
func
)
{
switch
(
type
)
{
...
...
@@ -124,7 +124,7 @@ nervana::log_helper::log_helper(LOG_TYPE type, const char* file, int line, const
_stream
<<
"
\t
"
;
}
n
ervana
::
log_helper
::~
log_helper
()
n
graph
::
log_helper
::~
log_helper
()
{
cout
<<
_stream
.
str
()
<<
endl
;
// logger::log_item(_stream.str());
...
...
src/ngraph/log.hpp
View file @
92e5a8ee
...
...
@@ -20,7 +20,7 @@
#include <sstream>
#include <stdexcept>
namespace
n
ervana
namespace
n
graph
{
class
conststring
{
...
...
@@ -93,30 +93,30 @@ namespace nervana
extern
std
::
ostream
&
get_nil_stream
();
#define NGRAPH_ERR \
n
ervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_ERROR,
\
nervana::get_file_name(__FILE__),
\
__LINE__,
\
__PRETTY_FUNCTION__)
\
n
graph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_ERROR,
\
ngraph::get_file_name(__FILE__),
\
__LINE__,
\
__PRETTY_FUNCTION__)
\
.stream()
#define NGRAPH_WARN \
n
ervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_WARNING,
\
nervana::get_file_name(__FILE__),
\
__LINE__,
\
__PRETTY_FUNCTION__)
\
n
graph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_WARNING,
\
ngraph::get_file_name(__FILE__),
\
__LINE__,
\
__PRETTY_FUNCTION__)
\
.stream()
#define NGRAPH_INFO \
n
ervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_INFO,
\
nervana::get_file_name(__FILE__),
\
__LINE__,
\
__PRETTY_FUNCTION__)
\
n
graph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_INFO,
\
ngraph::get_file_name(__FILE__),
\
__LINE__,
\
__PRETTY_FUNCTION__)
\
.stream()
// #define NGRAPH_DEBUG \
// n
ervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_DEBUG,
\
//
nervana::get_file_name(__FILE__),
\
//
__LINE__,
\
//
__PRETTY_FUNCTION__)
\
// n
graph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_DEBUG,
\
//
ngraph::get_file_name(__FILE__),
\
//
__LINE__,
\
//
__PRETTY_FUNCTION__)
\
// .stream()
#define NGRAPH_DEBUG n
ervana
::get_nil_stream()
#define NGRAPH_DEBUG n
graph
::get_nil_stream()
}
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