Got tracing code working again.
This commit is contained in:
parent
e92bcf411d
commit
e70b80d6fe
5 changed files with 25 additions and 15 deletions
18
src/main.cc
18
src/main.cc
|
|
@ -57,16 +57,17 @@ static int read_and_report(report_t * report, int argc, char * argv[],
|
|||
process_environment(const_cast<const char **>(envp), "LEDGER_", report);
|
||||
TRACE_FINISH(environment, 1);
|
||||
|
||||
const char * p = std::getenv("HOME");
|
||||
path home = p ? p : "";
|
||||
optional<path> home;
|
||||
if (const char * home_var = std::getenv("HOME"))
|
||||
home = home_var;
|
||||
|
||||
if (! session.init_file)
|
||||
session.init_file = home / ".ledgerrc";
|
||||
session.init_file = home ? *home / ".ledgerrc" : "./.ledgerrc";
|
||||
if (! session.price_db)
|
||||
session.price_db = home / ".pricedb";
|
||||
session.price_db = home ? *home / ".pricedb" : "./.pricedb";
|
||||
|
||||
if (! session.cache_file)
|
||||
session.cache_file = home / ".ledger-cache";
|
||||
session.cache_file = home ? *home / ".ledger-cache" : "./.ledger-cache";
|
||||
|
||||
if (session.data_file == *session.cache_file)
|
||||
session.use_cache = false;
|
||||
|
|
@ -392,6 +393,11 @@ int main(int argc, char * argv[], char * envp[])
|
|||
if (std::strcmp(argv[i], "--verify") == 0)
|
||||
ledger::verify_enabled = true;
|
||||
#endif
|
||||
#if defined(LOGGING_ON)
|
||||
if (std::strcmp(argv[i], "--verbose") == 0 ||
|
||||
std::strcmp(argv[i], "-v") == 0)
|
||||
ledger::_log_level = LOG_INFO;
|
||||
#endif
|
||||
#if defined(DEBUG_ON)
|
||||
if (i + 1 < argc && std::strcmp(argv[i], "--debug") == 0) {
|
||||
ledger::_log_level = LOG_DEBUG;
|
||||
|
|
@ -410,6 +416,8 @@ int main(int argc, char * argv[], char * envp[])
|
|||
|
||||
try {
|
||||
std::ios::sync_with_stdio(false);
|
||||
boost::filesystem::path::default_name_check
|
||||
(boost::filesystem::portable_posix_name);
|
||||
|
||||
ledger::initialize();
|
||||
|
||||
|
|
|
|||
|
|
@ -218,10 +218,10 @@ void shutdown()
|
|||
amount_t::shutdown();
|
||||
|
||||
IF_VERIFY() {
|
||||
INFO("Ledger shutdown (Boost/libstdc++ may still hold memory)");
|
||||
INFO("Ledger ended (Boost/libstdc++ may still hold memory)");
|
||||
shutdown_memory_tracing();
|
||||
} else {
|
||||
INFO("Ledger shutdown");
|
||||
INFO("Ledger ended");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -690,8 +690,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
i != time_entries.end();
|
||||
i++)
|
||||
if (event.account == (*i).account)
|
||||
throw_(parse_error,
|
||||
"Cannot double check-in to the same account");
|
||||
throw_(parse_error, "Cannot double check-in to the same account");
|
||||
|
||||
time_entries.push_back(event);
|
||||
break;
|
||||
|
|
@ -839,9 +838,12 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
push_var<unsigned long> save_end_pos(end_pos);
|
||||
push_var<unsigned int> save_linenum(linenum);
|
||||
|
||||
pathname = resolve_path(pathname);
|
||||
if (*p != '~' && *p != '/')
|
||||
pathname = (pathname.branch_path() / path(p)).normalize();
|
||||
else
|
||||
pathname = resolve_path(p);
|
||||
|
||||
DEBUG("ledger.textual.include", "line " << linenum << ": " <<
|
||||
DEBUG("ledger.textual.include", "Line " << linenum << ": " <<
|
||||
"Including path '" << pathname.string() << "'");
|
||||
|
||||
include_stack.push_back
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ string::~string() {
|
|||
|
||||
namespace ledger {
|
||||
|
||||
log_level_t _log_level;
|
||||
log_level_t _log_level = LOG_WARN;
|
||||
std::ostream * _log_stream = &std::cerr;
|
||||
std::ostringstream _log_buffer;
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ bool logger_func(log_level_t level)
|
|||
|
||||
namespace ledger {
|
||||
|
||||
std::string _log_category;
|
||||
optional<std::string> _log_category;
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
|
|
|
|||
|
|
@ -238,10 +238,10 @@ extern unsigned int _trace_level;
|
|||
|
||||
#if defined(DEBUG_ON)
|
||||
|
||||
extern std::string _log_category;
|
||||
extern optional<std::string> _log_category;
|
||||
|
||||
inline bool category_matches(const char * cat) {
|
||||
return starts_with(_log_category, cat);
|
||||
return _log_category && starts_with(cat, *_log_category);
|
||||
}
|
||||
|
||||
#define SHOW_DEBUG(cat) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue