Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Facing issue with Python loggin logger for printing object value

Reply
Thread Tools

Facing issue with Python loggin logger for printing object value

 
 
Morten Engvoldsen
Guest
Posts: n/a
 
      12-28-2012
Hi Team,
i am new to python and i am using python loggin for log the value of the
object. Below is my code :

class field:
field_name = ""
length = 0
type = 0
value = ""

def __init__(self, field_name, length, type, value):
self.field_name = field_name
self.length = length
self.type = type
self.value = value

def toString(self):
if self.type == 2:
return self.value.zfill(self.length)
else:
return self.value.ljust(self.length).upper()
class record:
fields = []

def setValue(self, field_name, value):
for element in self.fields:
if field_name == element.field_name:
element.value = value

def toString(self):
_tempStr = ""
for element in self.fields:
_tempStr = _tempStr + element.toString()
if len(_tempStr) < 80:
return _tempStr
else:
_lines = len(_tempStr) / 80
_i = 0
_tempStr2 = ""
_newline = ""
while _i < _lines:
_tempStr2 = _tempStr2 + _newline + _tempStr[_i*80_i+1)*80]
_newline = "\n"
_i = _i + 1

return _tempStr2
class First_betfor00(record):

def __init__(self):
self.fields = [field("APPLICATION-HEADER", 40, 1, ""),
field("TRANSACTION-CODE", 8, 0, "BETFOR00"),
field("ENTERPRISE-NUMBER", 11, 2, ""),
field("DIVISION", 11, 1, ""),
field("SEQUENCE-CONTROL", 4, 2, ""),
field("RESERVED-1", 6, 1, ""),
field("PRODUCTION-DATE", 4, 1, "MMDD"),
field("PASSWORD", 10, 1, ""),
field("VERSION", 10, 1, "VERSJON002"),
field("NEW-PASSWORD", 10, 1, ""),
field("OPERATOR-NO", 11, 1, ""),
field("SIGILL-SEAL-USE", 1, 1, ""),
field("SIGILL-SEAL-DATE", 6, 1, ""),
field("SIGILL-SEAL-KEY", 20, 1, ""),
field("SIGILL-SEAL-HOW", 1, 1, ""),
field("RESERVED-2", 143, 1, ""),
field("OWN-REFERENCE-BATCH", 15, 1, ""),
field("RESERVED-3", 9, 1, ""),
]
class account(osv.osv_memory):
_name = 'account'

def create(self,cr,uid,ids,context):
logger = logging.getLogger('account')
hdlr = logging.FileHandler('/var/tmp/account')
formatter = logging.Formatter('%(asctime)s, %(levelname)s,
%(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)

batch = ""
recordCounter = 1
dateMMDD = time.strftime('%m%d')

betfor00 = Format_betfor00()
betfor00.setValue("APPLICATION-HEADER",
applicationHeader.toString())
betfor00.setValue("ENTERPRISE-NUMBER", enterpriseNumber)
betfor00.setValue("PRODUCTION-DATE", dateMMDD)
batch = betfor00.toString()

line_counter = line_counter + 1
log.debug('%(batch)s')
return {'type': 'state', 'state':'end'}
account()


In the above code i am trying to capture the value of 'batch' in the log
file, but when i check log file it doesn't have any value printed. my
question is is it correct way to capture the object value that is
log.debug('%(batch)s')

I will really appreciate the answer. Thanks in advance..

Regards,
Morten

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Facing issue with Python loggin logger for printing object value Dave Angel Python 0 12-29-2012 04:41 PM
Re: Facing issue with Python loggin logger for printing object value Chris Angelico Python 0 12-29-2012 12:53 PM
Re: Facing issue with Python loggin logger for printing object value Morten Engvoldsen Python 0 12-29-2012 12:39 PM
Re: Facing issue with Python loggin logger for printing object value Dave Angel Python 0 12-28-2012 06:59 PM
Re: Facing issue with Python loggin logger for printing object value Dave Angel Python 0 12-28-2012 03:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57