2013-07-16 01:43:32 +00:00
|
|
|
/*
|
2013-07-19 17:29:33 +00:00
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
2013-07-16 01:43:32 +00:00
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
2013-07-19 17:29:33 +00:00
|
|
|
Author: Leonardo de Moura
|
2013-07-16 01:43:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "trace.h"
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#ifndef LEAN_TRACE_OUT
|
|
|
|
#define LEAN_TRACE_OUT ".lean_trace"
|
2013-07-19 17:29:33 +00:00
|
|
|
#endif
|
2013-07-16 01:43:32 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
|
|
|
|
#ifdef LEAN_TRACE
|
|
|
|
std::ofstream tout(LEAN_TRACE_OUT);
|
|
|
|
std::mutex trace_mutex;
|
|
|
|
#endif
|
2013-07-19 17:29:33 +00:00
|
|
|
|
2013-07-16 01:43:32 +00:00
|
|
|
static std::unique_ptr<std::set<std::string>> g_enabled_trace_tags;
|
|
|
|
|
|
|
|
void enable_trace(char const * tag) {
|
|
|
|
if (!g_enabled_trace_tags)
|
|
|
|
g_enabled_trace_tags.reset(new std::set<std::string>());
|
|
|
|
g_enabled_trace_tags->insert(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
void disable_trace(char const * tag) {
|
2013-07-19 17:29:33 +00:00
|
|
|
if (g_enabled_trace_tags)
|
2013-07-16 01:43:32 +00:00
|
|
|
g_enabled_trace_tags->erase(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_trace_enabled(char const * tag) {
|
|
|
|
return g_enabled_trace_tags && g_enabled_trace_tags->find(tag) != g_enabled_trace_tags->end();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|