Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35719
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'skip:[ 20': 0.03; 'syntax': 0.03; 'subject:Python': 0.05; 'formatting': 0.07; 'method,': 0.07; 'type,': 0.07; 'used.': 0.07; 'python': 0.09; "%s'": 0.09; '40,': 0.09; 'logger': 0.09; 'wrong,': 0.09; 'advance': 0.10; 'def': 0.10; 'thread': 0.11; '2.7': 0.13; 'ignore': 0.13; 'file,': 0.15; 'value.': 0.15; '""),': 0.16; '(starting': 0.16; 'again..': 0.16; 'field_name': 0.16; 'length,': 0.16; 'loggin': 0.16; 'record:': 0.16; 'subject:issue': 0.16; 'subject:object': 0.16; 'wrote:': 0.17; 'element': 0.17; 'team,': 0.18; 'issue.': 0.20; 'file.': 0.20; 'all,': 0.21; 'trying': 0.21; 'fixing': 0.22; 'object.': 0.22; 'skip:% 10': 0.22; 'skip:_ 20': 0.22; 'programming': 0.23; '15,': 0.23; 'errors': 0.23; 'mention': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'wrote': 0.26; 'am,': 0.27; 'language.': 0.27; 'skip:b 30': 0.27; 'question': 0.27; "doesn't": 0.28; 'correct': 0.28; 'run': 0.28; 'environment': 0.29; 'skip:_ 10': 0.29; 'probably': 0.29; 'class': 0.29; "skip:' 10": 0.30; 'stuff': 0.30; 'code': 0.31; 'file': 0.32; 'could': 0.32; 'skip:s 30': 0.33; '11,': 0.33; 'to:addr :python-list': 0.33; 'that,': 0.34; 'thanks': 0.34; 'skip:l 30': 0.35; 'really': 0.36; 'but': 0.36; "didn't": 0.36; 'subject:with': 0.36; 'should': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'skip:l 20': 0.38; 'things': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'different': 0.63; 'here': 0.65; '20,': 0.65; 'detail.': 0.65; 'stuck': 0.65; 'subject': 0.66; 'header:Reply-To:1': 0.68; 'answer.': 0.71; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'self.value': 0.84; 'subject:printing': 0.84; 'subject:value': 0.84 |
| Date | Fri, 28 Dec 2012 13:59:11 -0500 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Facing issue with Python loggin logger for printing object value |
| References | <CAJ2vgs7H8XsLaLmSCxP76raX1A4HFAsg63-NNb9Q0XU=XpNjpA@mail.gmail.com> |
| In-Reply-To | <CAJ2vgs7H8XsLaLmSCxP76raX1A4HFAsg63-NNb9Q0XU=XpNjpA@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:KB5CwzzjYho7vlU5nVAE0IQVjwE0AEzx85Rml2vrhcR qJ8PrgY8VcX4wRIqXkND+1bSXx2nEO1yXBT43f7LMeD35Jc1w2 pN+w4ldru3ZfB9aEK9keM20B4iIfLB4D2xTv7+lwLCOKTEoedR QYwrk+iC7xbBrXXHxsUMFLhEs5/jLJQ21SVSoqex+N6QzRkM22 O4XFQwiwHSiZeT8TAqDdvk9tmKAPDk5kyUOKfojfPiWs7Oy4zA aAptcg/dHHVbZogXTYvYtBMNL46XAP1ye2Wu8Sk9uy/pKOupGP ovFUe8bhxtr1FC6keSIgU2WdYudbJ+upOfpxcDehtq2ucR6Pg= = |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | d@davea.name |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1411.1356721171.29569.python-list@python.org> (permalink) |
| Lines | 143 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356721171 news.xs4all.nl 6982 [2001:888:2000:d::a6]:37983 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35719 |
Show key headers only | View raw
On 12/28/2012 09:27 AM, Morten Engvoldsen wrote:
> 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
>
>
Then Morten wrote (starting a redundant thread with different subject line):
Hi Dave,
Thanks for looking into my issue. You cannot run the program since it is
in Openerp where python is used as programming language. Here python 2.7 is
used. Sorry i didn't mention all the detail.
My program is able to write log for other message in the log file. here
'batch' is an object and when i try to log the value of 'batch' with
logger.debug('The value is %s' %batch) , it doesn't log the value. I am not
sure if it is the correct if it correct formatting syntax for displaying
Object value.
Thanks in advance again.. I am new to Python but not in programming
language..
....................................
Does this "openerp' environment ignore syntax errors? Can you see when things go wrong, or are you stuck with only looking at the zero-length log file ?
After "fixing" perhaps a half-dozen errors in that one create() method, and fixing lots of other stuff so I could run it at all, I came across the particular clue you're probably missing.
logger.setLevel(logging.DEBUG)
Without that, the logger doesn't know which messages should be logged.
--
DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Facing issue with Python loggin logger for printing object value Dave Angel <d@davea.name> - 2012-12-28 13:59 -0500
csiph-web