Commit 92e5a8ee authored by Robert Kimball's avatar Robert Kimball Committed by Scott Cyphers

move log from nervana to ngraph namespace (#496)

parent 9348da6d
......@@ -26,45 +26,45 @@
using namespace std;
namespace nervana
namespace ngraph
{
class thread_starter;
}
string nervana::logger::log_path;
deque<string> nervana::logger::queue;
string ngraph::logger::log_path;
deque<string> ngraph::logger::queue;
static mutex queue_mutex;
static condition_variable queue_condition;
static unique_ptr<thread> queue_thread;
static bool active = false;
std::ostream& nervana::get_nil_stream()
std::ostream& ngraph::get_nil_stream()
{
static std::stringstream nil;
return nil;
}
class nervana::thread_starter
class ngraph::thread_starter
{
public:
thread_starter() { nervana::logger::start(); }
virtual ~thread_starter() { nervana::logger::stop(); }
thread_starter() { ngraph::logger::start(); }
virtual ~thread_starter() { ngraph::logger::stop(); }
};
static nervana::thread_starter _starter;
static ngraph::thread_starter _starter;
void nervana::logger::set_log_path(const string& path)
void ngraph::logger::set_log_path(const string& path)
{
log_path = path;
}
void nervana::logger::start()
void ngraph::logger::start()
{
active = true;
queue_thread = unique_ptr<thread>(new thread(&thread_entry, nullptr));
}
void nervana::logger::stop()
void ngraph::logger::stop()
{
{
unique_lock<std::mutex> lk(queue_mutex);
......@@ -74,12 +74,12 @@ void nervana::logger::stop()
queue_thread->join();
}
void nervana::logger::process_event(const string& s)
void ngraph::logger::process_event(const string& s)
{
cout << s << "\n";
}
void nervana::logger::thread_entry(void* param)
void ngraph::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 nervana::logger::log_item(const string& s)
void ngraph::logger::log_item(const string& s)
{
unique_lock<std::mutex> lk(queue_mutex);
queue.push_back(s);
queue_condition.notify_one();
}
nervana::log_helper::log_helper(LOG_TYPE type, const char* file, int line, const char* func)
ngraph::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";
}
nervana::log_helper::~log_helper()
ngraph::log_helper::~log_helper()
{
cout << _stream.str() << endl;
// logger::log_item(_stream.str());
......
......@@ -20,7 +20,7 @@
#include <sstream>
#include <stdexcept>
namespace nervana
namespace ngraph
{
class conststring
{
......@@ -93,30 +93,30 @@ namespace nervana
extern std::ostream& get_nil_stream();
#define NGRAPH_ERR \
nervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_ERROR, \
nervana::get_file_name(__FILE__), \
__LINE__, \
__PRETTY_FUNCTION__) \
ngraph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_ERROR, \
ngraph::get_file_name(__FILE__), \
__LINE__, \
__PRETTY_FUNCTION__) \
.stream()
#define NGRAPH_WARN \
nervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_WARNING, \
nervana::get_file_name(__FILE__), \
__LINE__, \
__PRETTY_FUNCTION__) \
ngraph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_WARNING, \
ngraph::get_file_name(__FILE__), \
__LINE__, \
__PRETTY_FUNCTION__) \
.stream()
#define NGRAPH_INFO \
nervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_INFO, \
nervana::get_file_name(__FILE__), \
__LINE__, \
__PRETTY_FUNCTION__) \
ngraph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_INFO, \
ngraph::get_file_name(__FILE__), \
__LINE__, \
__PRETTY_FUNCTION__) \
.stream()
// #define NGRAPH_DEBUG \
// nervana::log_helper(nervana::LOG_TYPE::_LOG_TYPE_DEBUG, \
// nervana::get_file_name(__FILE__), \
// __LINE__, \
// __PRETTY_FUNCTION__) \
// ngraph::log_helper(ngraph::LOG_TYPE::_LOG_TYPE_DEBUG, \
// ngraph::get_file_name(__FILE__), \
// __LINE__, \
// __PRETTY_FUNCTION__) \
// .stream()
#define NGRAPH_DEBUG nervana::get_nil_stream()
#define NGRAPH_DEBUG ngraph::get_nil_stream()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment