summaryrefslogtreecommitdiff
path: root/session.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-27 10:09:14 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:32 -0400
commita85bd282d7868cd1d7b7f166a2e8d2f13abfde13 (patch)
tree1682fa1da36756eabbe04ab2df1b60e557dbfee8 /session.cc
parentd0e9822ed16cb36de4cb1171a89d4049c615f1a0 (diff)
downloadfork-ledger-a85bd282d7868cd1d7b7f166a2e8d2f13abfde13.tar.gz
fork-ledger-a85bd282d7868cd1d7b7f166a2e8d2f13abfde13.tar.bz2
fork-ledger-a85bd282d7868cd1d7b7f166a2e8d2f13abfde13.zip
Pounded the logging and memory tracing code into better shape.
Diffstat (limited to 'session.cc')
-rw-r--r--session.cc36
1 files changed, 27 insertions, 9 deletions
diff --git a/session.cc b/session.cc
index 25d040ff..13cdd286 100644
--- a/session.cc
+++ b/session.cc
@@ -62,13 +62,11 @@ journal_t * session_t::read_data(const string& master_account)
unsigned int entry_count = 0;
- DEBUG_("ledger.cache",
- "3. use_cache = " << use_cache);
+ DEBUG_("ledger.cache", "3. use_cache = " << use_cache);
if (use_cache && ! cache_file.empty() &&
! data_file.empty()) {
- DEBUG_("ledger.cache",
- "using_cache " << cache_file);
+ DEBUG_("ledger.cache", "using_cache " << cache_file);
cache_dirty = true;
if (access(cache_file.c_str(), R_OK) != -1) {
std::ifstream stream(cache_file.c_str());
@@ -95,14 +93,12 @@ journal_t * session_t::read_data(const string& master_account)
if (read_journal(journal->price_db, journal)) {
throw_(exception, "Entries not allowed in price history file");
} else {
- DEBUG_("ledger.cache",
- "read price database " << journal->price_db);
+ DEBUG_("ledger.cache", "read price database " << journal->price_db);
journal->sources.pop_back();
}
}
- DEBUG_("ledger.cache",
- "rejected cache, parsing " << data_file);
+ DEBUG_("ledger.cache", "rejected cache, parsing " << data_file);
if (data_file == "-") {
use_cache = false;
journal->sources.push_back("<stdin>");
@@ -171,14 +167,26 @@ xml::xpath_t::op_t * session_t::lookup(const string& name)
if (std::strncmp(p, "option_", 7) == 0) {
p = p + 7;
switch (*p) {
+ case 'd':
+ if (std::strcmp(p, "debug") == 0)
+ return MAKE_FUNCTOR(session_t, option_debug);
+ break;
+
case 'f':
if (! *(p + 1) || std::strcmp(p, "file") == 0)
return MAKE_FUNCTOR(session_t, option_file);
break;
+ case 't':
+ if (std::strcmp(p, "trace") == 0)
+ return MAKE_FUNCTOR(session_t, option_trace);
+ break;
+
case 'v':
- if (std::strcmp(p, "verbose") == 0)
+ if (! *(p + 1) || std::strcmp(p, "verbose") == 0)
return MAKE_FUNCTOR(session_t, option_verbose);
+ else if (std::strcmp(p, "verify") == 0)
+ return MAKE_FUNCTOR(session_t, option_verify);
break;
}
}
@@ -192,7 +200,11 @@ xml::xpath_t::op_t * session_t::lookup(const string& name)
// session_t object
void initialize()
{
+ IF_VERIFY()
+ initialize_memory_tracing();
+
amount_t::initialize();
+ xml::xpath_t::initialize();
}
void shutdown()
@@ -200,7 +212,13 @@ void shutdown()
#if defined(USE_BOOST_PYTHON)
shutdown_for_python();
#endif
+ xml::xpath_t::shutdown();
amount_t::shutdown();
+
+ IF_VERIFY() {
+ TRACE(1, "Shutting down memory trace");
+ shutdown_memory_tracing();
+ }
}
} // namespace ledger