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
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef LEAN_TRACE
|
2013-12-09 22:56:48 +00:00
|
|
|
#include "util/thread.h"
|
2013-09-13 10:35:29 +00:00
|
|
|
#include <fstream>
|
2013-07-16 01:43:32 +00:00
|
|
|
namespace lean {
|
2013-07-19 17:29:33 +00:00
|
|
|
extern std::ofstream tout;
|
2013-12-09 22:56:48 +00:00
|
|
|
extern mutex trace_mutex;
|
2013-07-16 01:43:32 +00:00
|
|
|
}
|
2013-12-09 22:56:48 +00:00
|
|
|
#define TRACE_CODE(CODE) { lock_guard<mutex> _lean_trace_lock_(lean::trace_mutex); CODE }
|
2013-07-16 01:43:32 +00:00
|
|
|
#else
|
2013-07-19 17:29:33 +00:00
|
|
|
#define TRACE_CODE(CODE)
|
2013-07-16 01:43:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define lean_trace(TAG, CODE) TRACE_CODE(if (lean::is_trace_enabled(TAG)) { lean::tout << "-------- [" << TAG << "] " << __FUNCTION__ << " " << __FILE__ << ":" << __LINE__ << " ---------\n"; CODE lean::tout << "------------------------------------------------\n"; lean::tout.flush(); })
|
|
|
|
|
|
|
|
#define lean_simple_trace(TAG, CODE) TRACE_CODE(if (lean::is_trace_enabled(TAG)) { CODE lean::tout.flush(); })
|
|
|
|
|
|
|
|
#define lean_cond_trace(TAG, COND, CODE) TRACE_CODE(if (lean::is_trace_enabled(TAG) && (COND)) { lean::tout << "-------- [" << TAG << "] " << __FUNCTION__ << " " << __FILE__ << ":" << __LINE__ << " ---------\n"; CODE lean::tout << "------------------------------------------------\n"; lean::tout.flush(); })
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
void enable_trace(char const * tag);
|
|
|
|
void disable_trace(char const * tag);
|
|
|
|
bool is_trace_enabled(char const * tag);
|
|
|
|
}
|