From 33bb6d66fd29039576844c49ceceefe905d68fd3 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 11 Jun 2010 16:32:20 +0000 Subject: [PATCH] more data stored in verbose mode --- accounts.py | 3 ++- database.py | 7 +++++-- logger.py | 11 ++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/accounts.py b/accounts.py index c064ec6..ffb9d52 100644 --- a/accounts.py +++ b/accounts.py @@ -25,7 +25,6 @@ numbers of accounts, this may cause the NM process to run out of maximum stack size. """ -#import Queue import os import pwd, grp import threading @@ -135,6 +134,8 @@ class Worker: def ensure_created(self, rec, startingup = Startingup): """Check account type is still valid. If not, recreate sliver. If still valid, check if running and configure/start if not.""" + logger.log_data_in_file(rec,"/var/lib/nodemanager/%s.rec.txt"%rec['name'], + 'raw rec captured in ensure_created',logger.LOG_VERBOSE) curr_class = self._get_class() next_class = type_acct_class[rec['type']] if next_class != curr_class: diff --git a/database.py b/database.py index 16ca104..1985b58 100644 --- a/database.py +++ b/database.py @@ -169,8 +169,11 @@ It proceeds to handle dump requests forever.""" db_pickle = cPickle.dumps(db, cPickle.HIGHEST_PROTOCOL) dump_requested = False db_lock.release() - try: tools.write_file(DB_FILE, lambda f: f.write(db_pickle)) - except: logger.log_exc("database: failed in database.start.run") + try: + tools.write_file(DB_FILE, lambda f: f.write(db_pickle)) + logger.log_database(db) + except: + logger.log_exc("database.start: failed to pickle/dump") global db try: f = open(DB_FILE) diff --git a/logger.py b/logger.py index b30031f..f008806 100644 --- a/logger.py +++ b/logger.py @@ -11,8 +11,8 @@ import select LOG_FILE = '/var/log/nodemanager' LOG_SLIVERS = '/var/lib/nodemanager/getslivers.txt' +LOG_DATABASE = '/var/lib/nodemanager/database.txt' -# Thierry - trying to debug this for 4.2 # basically define 3 levels LOG_NONE=0 LOG_NODE=1 @@ -55,7 +55,9 @@ def log_exc(msg="",name=None): def log_missing_data (msg,key): log("%s: could not find the %s key in data (PLC connection down?) - IGNORED"%(msg,key)) -def log_data_in_file (data, file, message=""): +def log_data_in_file (data, file, message="",level=LOG_NODE): + if (level > LOG_LEVEL): + return import pprint, time try: f=open(file,'w') @@ -65,11 +67,14 @@ def log_data_in_file (data, file, message=""): pp=pprint.PrettyPrinter(stream=f,indent=2) pp.pprint(data) f.close() + log("logger:.log_data_in_file Owerwrote %s"%file) except: - log_verbose('log_data_in_file failed - file=%s - message=%r'%(file,message)) + log_exc('logger.log_data_in_file failed - file=%s - message=%r'%(file,message)) def log_slivers (data): log_data_in_file (data, LOG_SLIVERS, "raw GetSlivers") +def log_database (db): + log_data_in_file (db, LOG_DATABASE, "raw database") #################### child processes # avoid waiting until the process returns; -- 2.43.0