Re: logging output

2018-10-19 Thread Anders Wegge Keller
På Fri, 19 Oct 2018 08:05:28 -0700 (PDT)
Sharan Basappa  skrev:

...

> delimiter=r'\s"') #data_df = pd.read_csv("BGL_MERGED.log")
> logger.debug("data frame %s \n", data_df)

 Do this help?
 


-- 

//Wegge
-- 
https://mail.python.org/mailman/listinfo/python-list


logging output

2018-10-19 Thread Sharan Basappa
I am loading a csv file using Pandas and then logging it back into another file 
using logging module.

Here is one sample line from input file:
- 1117838570 2005.06.03 R02-M1-N0-C:J12-U11 2005-06-03-15.42.50.675872 
R02-M1-N0-C:J12-U11 RAS KERNEL INFO instruction cache parity error corrected

Here the sample line from logging output
0   - 1117838570 2005.06.03 R02-M1-N0-C:J12-U11 20...

The lines seems to be same but logging module seems to be cutting down 
additional columns towards the end (see "..." characters).

Am I missing something?

below is the full code listing:

import sys
import pandas as pd
import numpy as np
import logging

#Create and configure logger
logging.basicConfig(filename="debug.log", filemode='w', format='%(asctime)s 
%(message)s')
logger = logging.getLogger()
logger.setLevel(logging.DEBUG) 

data_df = pd.read_csv("BGL_MERGED.log", nrows=100, header=None, 
delimiter=r'\s"')
#data_df = pd.read_csv("BGL_MERGED.log")
logger.debug("data frame %s \n", data_df)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24352] Provide a way for assertLogs to optionally not hide the logging output

2015-08-21 Thread R. David Murray

R. David Murray added the comment:

My test harness already dumps the logging buffer on test failure.

What I need this for is debugging.  My test harness verbose = 2 flag turns on 
logging globally, and I need to see the logging from the code under test 
correctly interspersed with the other logging (some of which comes from *other 
processes*...there are integration tests as well as unit tests).

Here's what I'm currently using:

@contextmanager
def assertLogs(self, logger=None, level=None):
cm = super().assertLogs(logger, level)
watcher = cm.__enter__()
if verbose  1:
capture_handler = cm.logger.handlers
cm.logger.propagate = cm.old_propagate
cm.logger.handlers = cm.old_handlers + cm.logger.handlers
try:
yield watcher
finally:
if verbose  1:
# Restore before exit to avoid a race.  Otherwise debug output
# sometimes gets written to the console during non-v.
cm.logger.propagate = False
cm.logger.handlers = capture_handler
cm.__exit__(None, None, None)

So, I have a solution, and if my use case is too specialized I can just 
continue to use that solution, though I am forced to poke at the internals to 
make it work :)

I am also, by the way, depending on the fact that when the logging is being 
done by another thread I can watch cm.output until specific logging that I am 
expecting appears in the buffer.  I'm sure that's going to make some people 
throw up their hands in disgust, considering among other things the fact that 
it involves a busy-wait, but while it may be a somewhat ugly hack, it is a hack 
that works well.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24352
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24352] Provide a way for assertLogs to optionally not hide the logging output

2015-08-20 Thread Robert Collins

Robert Collins added the comment:

Ok so, design thoughts here.

assertLogs really does two things. Firstly it takes a copy of the logs so it 
can do its assertion.

Secondly it disables all other logging, cleaning up noisy tests.

Your specific need only conflicts with the second case.

The way I handle this in 'fixtures' is to automatically attach the logs to the 
test output, which means failures show the logs. (Successes have them too, but 
they are not shown by default).

Ignoring the mismatch between stock unittest and fixtures supporting unittests, 
does this sound like it would meet your needs? e.g. you'd use your global to 
make attachments be shown on success as well as failure, and then you'd have 
nearly identical behaviour. But not exactly:  it would still disable the 
during-execution output (which makes parallel and CI runs a lot nicer - the 
report at the end is the key).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24352
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Optimal solution for coloring logging output

2015-08-03 Thread Mark Lawrence

On 03/08/2015 10:13, c.bu...@posteo.jp wrote:

I don't want to ask how to do this because there are so many
solutions about it.
http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output

There are so much different and part of unpythontic solutions I can not
decide myself. What do you (as real pythontics) think about that.
Which of the solutions fit to concepts of Python and its logging
package?

Coloring means here not only the message itself. The (levelname) should
be included in the coloring.
For myself coloring the (levelname) would be enough to avoid to much
color in the output.

1.
The solution itself shouldn't care about plattform differences because
there are still some packages which are able to offer
plattform-independent console-coloring. Which would you prefere? ;)

2.
Some solutions derive from StreamHandler or much more bad hacking the
emit() function. I think both of them are not responsible for how the
output should look or be presented.

3.
How to present the output is IMO the responsibility of a Formater, isn't
it? So I should derive from the Formater.

What do you as Pythonics think of that? ;)



I'd go for this https://pypi.python.org/pypi/colorlog as recommended on 
a couple of answers on the stackoverflow thread you've referenced.


A slight aside, we're Pythonistas, not pythontics or Pythonics  :)

take cover
Should we subclass Pythonista into Pythonista2 and Pythonista3 so that 
people can show their preferred version?

/take cover

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Optimal solution for coloring logging output

2015-08-03 Thread c.buhtz
I don't want to ask how to do this because there are so many
solutions about it.
http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output

There are so much different and part of unpythontic solutions I can not
decide myself. What do you (as real pythontics) think about that.
Which of the solutions fit to concepts of Python and its logging
package?

Coloring means here not only the message itself. The (levelname) should
be included in the coloring.
For myself coloring the (levelname) would be enough to avoid to much
color in the output.

1.
The solution itself shouldn't care about plattform differences because
there are still some packages which are able to offer
plattform-independent console-coloring. Which would you prefere? ;)

2.
Some solutions derive from StreamHandler or much more bad hacking the
emit() function. I think both of them are not responsible for how the
output should look or be presented.

3.
How to present the output is IMO the responsibility of a Formater, isn't
it? So I should derive from the Formater.

What do you as Pythonics think of that? ;)
-- 
-BEGIN PGP PUBLIC KEY BLOCK-
Version: GnuPG v1

mQENBFQIluABCACfPwAhRAwFD3NXgv5CtVUGSiqdfJGVViVBqaKd+14E0pASA0MU
G0Ewj7O7cGy/ZIoiZ0+lIEZmzJKHfuGwYhXjR/PhnUDrQIHLBvh9WuD6JQuULXfH
kXtVm/i9wm76QAcvr2pwYgNzhcJntUHl2GcgnInYbZDeVmg+p9yIPJjuq73/lRS3
0/McgNoFOBhKK/S6STQuFyjr9OyJyYd1shoM3hmy+kg0HYm6OgQBJNg92WV9jwGe
GzlipvEp2jpLwVsTxYir2oOPhfd9D1fC9F/l/3gXbfjd5GIIVrZFq2haZmoVeJ33
LJxo3RA5Tf9LoUeels1b4s9kFz6h7+AHERUpABEBAAG0IUNocmlzdGlhbiBCdWh0
eiA8YnVodHpAcG9zdGVvLmRlPokBPgQTAQIAKAUCVAiW4AIbAwUJAeEzgAYLCQgH
AwIGFQgCCQoLBBYCAwECHgECF4AACgkQZLsXsAdRqOxNUAf/V/hDA5zGDpySuCEj
DhjiVRK74J9Wd8gfH0WAf1Co5HZ24wZH8rgOIVIgXw8rWkOw/VA6xfdfT+64xjTY
Fhkpbrk199nDzp72F7Jc4NC+x8xac2e3rK5ifSWhZx7L5A32pGYE+d16m3EEqImK
D4gcZl38x9zdUnD4hHyXkIPz1uCfuMuGgWEnaUk4Wbj41CBZr3O0ABue6regV15U
jaes8r+B8iCcY+0yP2kse+3iaCaMqNv5FgQZ9+b2Cql8pFkZJVtBVUw4GW3DWZJi
du0O/YrC9TgS+xY9ht/MD2qSHwjcK1sdImjqBO7xP8TIOwKeYyDvGKnSO3EJ/sSA
UPGEPrkBDQRUCJbgAQgA0k/Qg67CCUJE2/zuxBEoK4wLJpDRJzh8CQPZpjWx8VP0
KL892jwfxymXn8KNhuy1SgCBFSeV9jg4VZNWDlUGJc2lo82ajr9PzIsrQwu4lf0B
zrUWV5hWepKu/kb8uSjx58YYfx0SFz4+9akX3Wwu9TUHntzL5Gk3Q26nnsr1xEJ+
VEumvCH9AE0Tk0K7dQpJ2/JcLuO+uhrpd/lHFDYVN5NsG3P015uFOkDI6N/xNFCj
v95XNR93QlfKpK3qWlFGescfG+o/7Ub6s67/i/JoNbw0XgPEHmQfXpD7IHO4cu+p
+ETb11cz+1mmi96cy98ID+uTiToJ8G//yD9rmtyxoQARAQABiQElBBgBAgAPBQJU
CJbgAhsMBQkB4TOAAAoJEGS7F7AHUajs6sQH/iKs6sPc0vkRJLfbwrijZeecwCWF
blo/jzIQ8jPykAj9SLjV20Xwqg3XcJyko8ZU6/zuRJq9xjlv9pZr/oVudQAt6v+h
2Cf4rKEjmau483wjMV2xjTXQhZi9+ttDbia4fgdmGtKsOicn5ae2fFXcXNPu3RiW
sZKifWdokA6xqMW6iIG9YjjI5ShxngHWp2xfPscBFMDRtFOMags/Yx+YvwoyEZ4A
dURYMFHFqpwILEc8hIzhRg1gq40AHbOaEdczS1Rr3T7/gS6eBs4u6HuY5g2Bierm
lLjpspFPjMXwJAa/XLOBjMF2vsHPrZNcouNKkumQ36yq/Pm6DFXAseQDxOk=
=PGP9
-END PGP PUBLIC KEY BLOCK-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Optimal solution for coloring logging output

2015-08-03 Thread Jean-Michel Pichavant
 Original Message -
 From: c buhtz c.bu...@posteo.jp
 To: python-list@python.org
 Sent: Monday, 3 August, 2015 11:13:37 AM
 Subject: Optimal solution for coloring logging output
 
 I don't want to ask how to do this because there are so many
 solutions about it.
 http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output
 
 There are so much different and part of unpythontic solutions I can
 not
 decide myself. What do you (as real pythontics) think about that.
 Which of the solutions fit to concepts of Python and its logging
 package?
 
 Coloring means here not only the message itself. The (levelname)
 should
 be included in the coloring.
 For myself coloring the (levelname) would be enough to avoid to much
 color in the output.
 
 1.
 The solution itself shouldn't care about plattform differences
 because
 there are still some packages which are able to offer
 plattform-independent console-coloring. Which would you prefere? ;)
 
 2.
 Some solutions derive from StreamHandler or much more bad hacking the
 emit() function. I think both of them are not responsible for how the
 output should look or be presented.
 
 3.
 How to present the output is IMO the responsibility of a Formater,
 isn't
 it? So I should derive from the Formater.
 
 What do you as Pythonics think of that? ;)

This is more or less how it could be done:

1/ use the module curses to get terminal colors (the doc suggests to use the 
Console moduel on windows)
2/ write a logging Formatter that will replace DEBUG/INFO/ERROR message by 
their colored version.


import curses
import logging
import string
import re

curses.setupterm()
class ColorFormat:
#{ Foregroung colors
BLACK = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_BLACK)
RED = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_RED)
GREEN = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_GREEN)
YELLOW = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_YELLOW)
BLUE = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_BLUE)
MAGENTA = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_MAGENTA)
CYAN = curses.tparm(curses.tigetstr('setaf'), curses.COLOR_CYAN)
WHITE = curses.tparm(curses.tigetstr('setaf'), 9) # default white is 7, 
the 9 is a better white
#{ Backgrounds colors
BG_BLACK = curses.tparm(curses.tigetstr('setab'), curses.COLOR_BLACK)
BG_RED = curses.tparm(curses.tigetstr('setab'), curses.COLOR_RED)
BG_GREEN = curses.tparm(curses.tigetstr('setab'), curses.COLOR_GREEN)
BG_YELLOW = curses.tparm(curses.tigetstr('setab'), curses.COLOR_YELLOW)
BG_BLUE = curses.tparm(curses.tigetstr('setab'), curses.COLOR_BLUE)
BG_MAGENTA = curses.tparm(curses.tigetstr('setab'), 
curses.COLOR_MAGENTA)
BG_CYAN = curses.tparm(curses.tigetstr('setab'), curses.COLOR_CYAN)
BG_WHITE = curses.tparm(curses.tigetstr('setab'), curses.COLOR_WHITE) 
#{ Format codes
BOLD = curses.tparm(curses.tigetstr('bold'), curses.A_BOLD)
UNDERLINE = curses.tparm(curses.tigetstr('smul'), curses.A_UNDERLINE)
BLINK = curses.tparm(curses.tigetstr('blink'), curses.A_BLINK)
NO_FORMAT = curses.tparm(curses.tigetstr('sgr0'), curses.A_NORMAL)
NO_COLOR = curses.tigetstr('sgr0')
#}

def setFormat(attributeList):
_set = '' # avoid collision with the builtin set type
for attribute in attributeList:
_set += getattr(ColorFormat, attribute, '')
return _set

class ColorFormatter(logging.Formatter):
def format(self, record):
parameters = record.__dict__.copy()
parameters['message'] = record.getMessage()

# 
--
# Log Level Format : %(levelname)
# 
--
fmt = self._fmt
pattern = r'(%\(levelname\)(?:-?\d+)?s)'
if record.levelno = logging.DEBUG:
fmt = re.sub(pattern, setFormat(['BLUE']) + r'\1' + 
 setFormat(['NO_COLOR']), fmt)
elif record.levelno = logging.INFO:
fmt = re.sub(pattern, setFormat(['CYAN']) + r'\1' + 
 setFormat(['NO_COLOR']), fmt)
elif record.levelno = logging.WARNING:
fmt = re.sub(pattern, setFormat(['MAGENTA']) + r'\1' + 
 setFormat(['NO_COLOR']), fmt)
elif record.levelno = logging.ERROR:
fmt = re.sub(pattern, setFormat(['RED','BOLD']) + r'\1' 
+ 
 setFormat(['NO_COLOR']), fmt)
else:
fmt

Re: Optimal solution for coloring logging output

2015-08-03 Thread Karim



On 03/08/2015 14:47, Jean-Michel Pichavant wrote:

te a logging Formatter that will re

Thank you Jean-Michel useful example

K
--
https://mail.python.org/mailman/listinfo/python-list


[issue24352] Provide a way for assertLogs to optionally not hide the logging output

2015-06-04 Thread Zachary Ware

Changes by Zachary Ware zachary.w...@gmail.com:


--
nosy: +zach.ware

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24352
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24352] Provide a way for assertLogs to optionally not hide the logging output

2015-06-02 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +ezio.melotti, michael.foord, rbcollins

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24352
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24352] Provide a way for assertLogs to optionally not hide the logging output

2015-06-01 Thread R. David Murray

New submission from R. David Murray:

In my test framework I have a 'verbose' flag that causes the logging output to 
be written to the console[*], which helps greatly during debugging.  However, 
if assertLogs is used, the logging is suppressed, and when debugging logging 
failures it is really helpful to see the full logging output :).

Ideally there would be a unittest-supported 'verbose' flag that assertLogs 
could look at and not suppress existing logging when it is at level 2 or 
greater.  Or perhaps a flag specific to logging output would be better?  I 
don't really care what the API is as long as I can arrange to set it from the 
CLI as part of running individual tests.

--
components: Library (Lib)
messages: 244608
nosy: r.david.murray
priority: normal
severity: normal
status: open
title: Provide a way for assertLogs to optionally not hide the logging output
type: enhancement
versions: Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24352
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Missing logging output in Python

2013-03-12 Thread W. Matthew Wilson
I made that code into a program like this:

### BEGIN

import logging

def configure_logging():

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s
%(name)-12s %(levelname)8s %(message)s',
datefmt='%Y-%m-%d\t%H:%M:%s',
filename='/tmp/logfun.log', filemode='a')

# define a Handler that writes INFO messages to sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)

# set format that is cleaber for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s
%(message)s')

# tell the handler to use this format
console.setFormatter(formatter)

# add the handler to the root logger
logging.getLogger('').addHandler(console)

if __name__ == '__main__':

configure_logging()

logging.debug('a')
logging.info('b')
logging.warn('c')
logging.error('d')
logging.critical('e')

### END

and when I run the program, I get INFO and greater messages to stderr:

$ python logfun.py
root: INFO b
root: WARNING  c
root: ERRORd
root: CRITICAL e

and I get this stuff in the log file:

$ cat /tmp/logfun.log
2013-03-12 07:31:1363087862 rootDEBUG a
2013-03-12 07:31:1363087862 root INFO b
2013-03-12 07:31:1363087862 root  WARNING c
2013-03-12 07:31:1363087862 rootERROR d
2013-03-12 07:31:1363087862 root CRITICAL e

In other words, your code works!  Maybe you should check permissions on the
file you are writing to.

Matt




On Fri, Mar 8, 2013 at 9:07 AM, gabor.a.hal...@gmail.com wrote:

 Hi,

 I would like to enable loggin in my script using the logging module that
 comes with Python 2.7.3.

 I have the following few lines setting up logging in my script, but for
 whatever reason  I don't seem to get any output to stdout  or to a file
 provided to the basicConfig method.

 Any ideas?

 # cinfiguring logging
 logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s
 %(levelname)8s %(message)s',
 datefmt='%Y-%m-%d\t%H:%M:%s',
 filename=config[currentLoop], filemode='a')
 # define a Handler that writes INFO messages to sys.stderr
 console = logging.StreamHandler()
 console.setLevel(logging.INFO)
 # set format that is cleaber for console use
 formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
 # tell the handler to use this format
 console.setFormatter(formatter)
 # add the handler to the root logger
 logging.getLogger('').addHandler(console)
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
W. Matthew Wilson
m...@tplus1.com
http://tplus1.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Missing logging output in Python

2013-03-08 Thread gabor . a . halasz
Hi,

I would like to enable loggin in my script using the logging module that comes 
with Python 2.7.3.

I have the following few lines setting up logging in my script, but for 
whatever reason  I don't seem to get any output to stdout  or to a file 
provided to the basicConfig method.

Any ideas?

# cinfiguring logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s 
%(levelname)8s %(message)s',
datefmt='%Y-%m-%d\t%H:%M:%s', 
filename=config[currentLoop], filemode='a')
# define a Handler that writes INFO messages to sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# set format that is cleaber for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)
-- 
http://mail.python.org/mailman/listinfo/python-list


Logging output to be redirected to a particular folder

2012-11-06 Thread anuradha . raghupathy2010
Hi,

Below is the python code that I have. I want to redirect the output to my C 
drive..myapp.log. 

I am editing and creating scripts in IDLE and running it as a python shell or 
module.

Can you help?

import logging

def main():
   logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)
   logging.debug('started debug')
   logging.info('info printing')
   logging.warning('test warning')
   logging.debug('debug again')
   logging.error('Error')

if __name__ == '__main__':
   main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging output to be redirected to a particular folder

2012-11-06 Thread Peter Otten
anuradha.raghupathy2...@gmail.com wrote:

 Hi,
 
 Below is the python code that I have. I want to redirect the output to my
 C drive..myapp.log.
 
 I am editing and creating scripts in IDLE and running it as a python shell
 or module.
 
 Can you help?
 
 import logging
 
 def main():
logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)

Python is case-sensitive. Try:

 logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)

logging.debug('started debug')
logging.info('info printing')
logging.warning('test warning')
logging.debug('debug again')
logging.error('Error')
 
 if __name__ == '__main__':
main()


-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Logging output to be redirected to a particular folder

2012-11-06 Thread Prasad, Ramit
Dennis Lee Bieber wrote:
 
 On Tue, 06 Nov 2012 13:26:11 +0100, Peter Otten __pete...@web.de
 declaimed the following in gmane.comp.python.general:
 
  anuradha.raghupathy2...@gmail.com wrote:
[snip]
   def main():
  logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)
 
  Python is case-sensitive. Try:
 
   logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)
 
   The double forward slashes might also be confusing... At the least,
 unneeded...
 
  import os.path
  print os.path.normpath(c://somefile.log)
 c:\somefile.log
  print os.path.normpath(c:\\somefile.log)
 c:\somefile.log
  print os.path.normpath(c:\\tryfile.log)
 c:\tryfile.log
  print os.path.normpath(c:\tryfile.log)
 c:ryfile.log
  print os.path.normpath(c:/tryfile.log)
 c:\tryfile.log
 
 
   Doubling back-slashes is needed to avoid the problem of literal
 escapes corrupting the intent...

Or use the raw literal form rc:\tryfile.log. I know several
people that prefer to use forward slashes as it works in both 
Windows and *nix.


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging output to be redirected to a particular folder

2012-11-06 Thread anuradha . raghupathy2010
Thanks ...this works perfectly fine now.

On Tuesday, November 6, 2012 11:28:46 PM UTC+5:30, Prasad, Ramit wrote:
 Dennis Lee Bieber wrote:
 
  
 
  On Tue, 06 Nov 2012 13:26:11 +0100, Peter Otten __pete...@web.de
 
  declaimed the following in gmane.comp.python.general:
 
  
 
   anuradha.raghupathy2...@gmail.com wrote:
 
 [snip]
 
def main():
 
   logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)
 
  
 
   Python is case-sensitive. Try:
 
  
 
logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)
 
  
 
  The double forward slashes might also be confusing... At the least,
 
  unneeded...
 
  
 
   import os.path
 
   print os.path.normpath(c://somefile.log)
 
  c:\somefile.log
 
   print os.path.normpath(c:\\somefile.log)
 
  c:\somefile.log
 
   print os.path.normpath(c:\\tryfile.log)
 
  c:\tryfile.log
 
   print os.path.normpath(c:\tryfile.log)
 
  c:  ryfile.log
 
   print os.path.normpath(c:/tryfile.log)
 
  c:\tryfile.log
 
  
 
  
 
  Doubling back-slashes is needed to avoid the problem of literal
 
  escapes corrupting the intent...
 
 
 
 Or use the raw literal form rc:\tryfile.log. I know several
 
 people that prefer to use forward slashes as it works in both 
 
 Windows and *nix.
 
 
 
 
 
 ~Ramit
 
 
 
 
 
 This email is confidential and subject to important disclaimers and
 
 conditions including on offers for the purchase or sale of
 
 securities, accuracy and completeness of information, viruses,
 
 confidentiality, legal privilege, and legal entity disclaimers,
 
 available at http://www.jpmorgan.com/pages/disclosures/email.

-- 
http://mail.python.org/mailman/listinfo/python-list


[ python-Bugs-1616422 ] Wrong pathname value in logging output

2006-12-18 Thread SourceForge.net
Bugs item #1616422, was opened at 2006-12-15 15:30
Message generated for change (Comment added) made by simleo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Tekkaman (simleo)
Assigned to: Vinay Sajip (vsajip)
Summary: Wrong pathname value in logging output

Initial Comment:
When trying to log caller pathname information, instead of the actual caller's 
name I get the full name of the logging module source file:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
/usr/lib/python2.4/logging/__init__.py


I've been discussing this on comp.lang.python and the suspect arised that this 
has something to do with a symlink in the path leading to the module source 
file (I have a lib - lib64 symlink on my system). To verify this I copied the 
entire logging directory into my home dir and retried. This is what I got:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
stdin


Additional info:
Python Version: 2.4.3
OS: Gentoo Linux 2.6.17-r8
CPU: AMD Turion(tm) 64 Mobile Technology
sys.path: ['', '/usr/lib/portage/pym', '/usr/lib/python24.zip', 
'/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', 
'/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', 
'/usr/lib64/python2.4/site-packages', 
'/usr/lib64/python2.4/site-packages/Numeric', 
'/usr/lib64/python2.4/site-packages/dbus', 
'/usr/lib64/python2.4/site-packages/gtk-2.0']


--

Comment By: Tekkaman (simleo)
Date: 2006-12-18 10:29

Message:
Logged In: YES 
user_id=1669352
Originator: YES

Deleting all .pyc and .pyo files solved the problem. Now I get the correct
behaviour. However, this is not an option for a machine on which one does
not have root privileges. Can the code be changed in such a way that it's
not fooled by outdated .pyc and .pyo files?

--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-16 23:38

Message:
Logged In: YES 
user_id=308438
Originator: NO

Right, but I'm not sure the problem's in logging. Logging uses the
filename built into the compiled code objects as it walks up the stack,
looking for a filename which is not the source file of the logging package.
Try deleting all your .pyc and .pyo files (including the ones in the
logging package) and see if there is a change in behaviour; what value does
logging._srcFile have? Does it accord with what you would expect? The
symlink could mean that the compiled filename in the .pyc/.pyo is out of
date.

--

Comment By: Tekkaman (simleo)
Date: 2006-12-16 20:03

Message:
Logged In: YES 
user_id=1669352
Originator: YES

I don't get stdin, I get /usr/lib/python2.4/logging/__init__.py. I got
stdin (correct behaviour) only after copying the entire logging directory
in the same place where I started the interpreter.

--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-15 18:20

Message:
Logged In: YES 
user_id=308438
Originator: NO

Sorry, why is this wrong? You are making the logging call from an
interactive prompt - so you would expect to get the pathname of stdin,
would you not?

I get the same output on Windows where the only logging module is the one
which is part of the standard Python installation.



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1616422 ] Wrong pathname value in logging output

2006-12-18 Thread SourceForge.net
Bugs item #1616422, was opened at 2006-12-15 14:30
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: Tekkaman (simleo)
Assigned to: Vinay Sajip (vsajip)
Summary: Wrong pathname value in logging output

Initial Comment:
When trying to log caller pathname information, instead of the actual caller's 
name I get the full name of the logging module source file:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
/usr/lib/python2.4/logging/__init__.py


I've been discussing this on comp.lang.python and the suspect arised that this 
has something to do with a symlink in the path leading to the module source 
file (I have a lib - lib64 symlink on my system). To verify this I copied the 
entire logging directory into my home dir and retried. This is what I got:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
stdin


Additional info:
Python Version: 2.4.3
OS: Gentoo Linux 2.6.17-r8
CPU: AMD Turion(tm) 64 Mobile Technology
sys.path: ['', '/usr/lib/portage/pym', '/usr/lib/python24.zip', 
'/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', 
'/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', 
'/usr/lib64/python2.4/site-packages', 
'/usr/lib64/python2.4/site-packages/Numeric', 
'/usr/lib64/python2.4/site-packages/dbus', 
'/usr/lib64/python2.4/site-packages/gtk-2.0']


--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-18 09:54

Message:
Logged In: YES 
user_id=308438
Originator: NO

Glad the problem's solved. It's not appropriate to change the current
behaviour of logging with respect to determining the source file of a
module, for a couple of reasons:

1) There are other problems caused by out-of-date .pyo and .pyc files
(every use of __file__ is potentially a problem) - which changing logging
would not solve. Logging uses __file__ how it is intended to be used.
2) Some systems are shipped with .pyo and .pyc files only - no .py files
are available (e.g. frozen systems).

--

Comment By: Tekkaman (simleo)
Date: 2006-12-18 09:29

Message:
Logged In: YES 
user_id=1669352
Originator: YES

Deleting all .pyc and .pyo files solved the problem. Now I get the correct
behaviour. However, this is not an option for a machine on which one does
not have root privileges. Can the code be changed in such a way that it's
not fooled by outdated .pyc and .pyo files?

--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-16 22:38

Message:
Logged In: YES 
user_id=308438
Originator: NO

Right, but I'm not sure the problem's in logging. Logging uses the
filename built into the compiled code objects as it walks up the stack,
looking for a filename which is not the source file of the logging package.
Try deleting all your .pyc and .pyo files (including the ones in the
logging package) and see if there is a change in behaviour; what value does
logging._srcFile have? Does it accord with what you would expect? The
symlink could mean that the compiled filename in the .pyc/.pyo is out of
date.

--

Comment By: Tekkaman (simleo)
Date: 2006-12-16 19:03

Message:
Logged In: YES 
user_id=1669352
Originator: YES

I don't get stdin, I get /usr/lib/python2.4/logging/__init__.py. I got
stdin (correct behaviour) only after copying the entire logging directory
in the same place where I started the interpreter.

--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-15 17:20

Message:
Logged In: YES 
user_id=308438
Originator: NO

Sorry, why is this wrong? You are making the logging call from an
interactive prompt - so you would expect to get the pathname of stdin,
would you not?

I get the same output on Windows where the only logging module is the one
which is part of the standard Python installation.



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1616422 ] Wrong pathname value in logging output

2006-12-16 Thread SourceForge.net
Bugs item #1616422, was opened at 2006-12-15 15:30
Message generated for change (Comment added) made by simleo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Tekkaman (simleo)
Assigned to: Vinay Sajip (vsajip)
Summary: Wrong pathname value in logging output

Initial Comment:
When trying to log caller pathname information, instead of the actual caller's 
name I get the full name of the logging module source file:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
/usr/lib/python2.4/logging/__init__.py


I've been discussing this on comp.lang.python and the suspect arised that this 
has something to do with a symlink in the path leading to the module source 
file (I have a lib - lib64 symlink on my system). To verify this I copied the 
entire logging directory into my home dir and retried. This is what I got:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
stdin


Additional info:
Python Version: 2.4.3
OS: Gentoo Linux 2.6.17-r8
CPU: AMD Turion(tm) 64 Mobile Technology
sys.path: ['', '/usr/lib/portage/pym', '/usr/lib/python24.zip', 
'/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', 
'/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', 
'/usr/lib64/python2.4/site-packages', 
'/usr/lib64/python2.4/site-packages/Numeric', 
'/usr/lib64/python2.4/site-packages/dbus', 
'/usr/lib64/python2.4/site-packages/gtk-2.0']


--

Comment By: Tekkaman (simleo)
Date: 2006-12-16 20:03

Message:
Logged In: YES 
user_id=1669352
Originator: YES

I don't get stdin, I get /usr/lib/python2.4/logging/__init__.py. I got
stdin (correct behaviour) only after copying the entire logging directory
in the same place where I started the interpreter.

--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-15 18:20

Message:
Logged In: YES 
user_id=308438
Originator: NO

Sorry, why is this wrong? You are making the logging call from an
interactive prompt - so you would expect to get the pathname of stdin,
would you not?

I get the same output on Windows where the only logging module is the one
which is part of the standard Python installation.



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1616422 ] Wrong pathname value in logging output

2006-12-15 Thread SourceForge.net
Bugs item #1616422, was opened at 2006-12-15 15:30
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Tekkaman (simleo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Wrong pathname value in logging output

Initial Comment:
When trying to log caller pathname information, instead of the actual caller's 
name I get the full name of the logging module source file:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
/usr/lib/python2.4/logging/__init__.py


I've been discussing this on comp.lang.python and the suspect arised that this 
has something to do with a symlink in the path leading to the module source 
file (I have a lib - lib64 symlink on my system). To verify this I copied the 
entire logging directory into my home dir and retried. This is what I got:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
stdin


Additional info:
Python Version: 2.4.3
OS: Gentoo Linux 2.6.17-r8
CPU: AMD Turion(tm) 64 Mobile Technology
sys.path: ['', '/usr/lib/portage/pym', '/usr/lib/python24.zip', 
'/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', 
'/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', 
'/usr/lib64/python2.4/site-packages', 
'/usr/lib64/python2.4/site-packages/Numeric', 
'/usr/lib64/python2.4/site-packages/dbus', 
'/usr/lib64/python2.4/site-packages/gtk-2.0']


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1616422 ] Wrong pathname value in logging output

2006-12-15 Thread SourceForge.net
Bugs item #1616422, was opened at 2006-12-15 14:30
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Pending
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Tekkaman (simleo)
Assigned to: Vinay Sajip (vsajip)
Summary: Wrong pathname value in logging output

Initial Comment:
When trying to log caller pathname information, instead of the actual caller's 
name I get the full name of the logging module source file:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
/usr/lib/python2.4/logging/__init__.py


I've been discussing this on comp.lang.python and the suspect arised that this 
has something to do with a symlink in the path leading to the module source 
file (I have a lib - lib64 symlink on my system). To verify this I copied the 
entire logging directory into my home dir and retried. This is what I got:

 import logging
 logging.basicConfig(format='%(pathname)s')
 logging.getLogger('').critical('foo')
stdin


Additional info:
Python Version: 2.4.3
OS: Gentoo Linux 2.6.17-r8
CPU: AMD Turion(tm) 64 Mobile Technology
sys.path: ['', '/usr/lib/portage/pym', '/usr/lib/python24.zip', 
'/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', 
'/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', 
'/usr/lib64/python2.4/site-packages', 
'/usr/lib64/python2.4/site-packages/Numeric', 
'/usr/lib64/python2.4/site-packages/dbus', 
'/usr/lib64/python2.4/site-packages/gtk-2.0']


--

Comment By: Vinay Sajip (vsajip)
Date: 2006-12-15 17:20

Message:
Logged In: YES 
user_id=308438
Originator: NO

Sorry, why is this wrong? You are making the logging call from an
interactive prompt - so you would expect to get the pathname of stdin,
would you not?

I get the same output on Windows where the only logging module is the one
which is part of the standard Python installation.



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1616422group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Logging output from python

2006-12-09 Thread Leonhard Vogt
Cameron Walsh schrieb:
 
 If it's on linux you can just redirect the screen output to a file:
 
 python initialfile.py 1stdout.txt 2stderr.txt


 As for windows, I'll test it now...
 
 It turns out you can at least redirect the output to a file, I'm not
 sure what it does with standard error or even if it exists or not.
 
 python initialfile.py  output.txt
 
 should work.

 cmd
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

 type output.py
import sys

print 'This is print.'
sys.stdout.write('This is stdout.write()\n')
sys.stderr.write('This is stderr.write()\n')

 python output.py 1stdout.txt 2stderr.txt

 type stdout.txt
This is print.
This is stdout.write()

 type stderr.txt
This is stderr.write()

Seems on XP it works too.

Leonhard
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging output from python

2006-12-08 Thread MRAB

Gabriel Genellina wrote:
 At Thursday 7/12/2006 23:21, Cameron Walsh wrote:

   Here is my problem. I want to log everything displayed in the screen
   after I start the main python script. Things include unhandled
   exceptions , message from print statement and other sources.
   Basically, if it is displayed on the screen, I want to log it..
 
 If it's on linux you can just redirect the screen output to a file:
 
 python initialfile.py 1stdout.txt 2stderr.txt
 [...]
 
 As for windows, I'll test it now...
 
 It turns out you can at least redirect the output to a file, I'm not
 sure what it does with standard error or even if it exists or not.
 
 python initialfile.py  output.txt

 It's the same syntax as noted for linux above. 1 is the same as  alone.

 If ALL the testing is done on a single program (that is, no os.system
 or spawn or subprocess...) then you could just replace sys.stdout and
 sys.stderr with another open file (or file-like) object.

Redirection in Windows is explained here:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

-- 
http://mail.python.org/mailman/listinfo/python-list


Logging output from python

2006-12-07 Thread Barry
Hi, guys

Basiclly, it is automated testing system. There is a main python script
that handles the testing campagin. This main script will call another
script that will in turn runs a few hundered individual python scripts.


Here is my problem. I want to log everything displayed in the screen
after I start the main python script. Things include unhandled
exceptions , message from print statement and other sources.
Basically, if it is displayed on the screen, I want to log it..


It might not be a pythons specific problem. Does anyone know a small
tool does that job?


Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging output from python

2006-12-07 Thread Cameron Walsh
Barry wrote:
 Hi, guys
 
 Basiclly, it is automated testing system. There is a main python script
 that handles the testing campagin. This main script will call another
 script that will in turn runs a few hundered individual python scripts.
 
 
 Here is my problem. I want to log everything displayed in the screen
 after I start the main python script. Things include unhandled
 exceptions , message from print statement and other sources.
 Basically, if it is displayed on the screen, I want to log it..
 
 
 It might not be a pythons specific problem. Does anyone know a small
 tool does that job?
 
 
 Thanks.
 

If it's on linux you can just redirect the screen output to a file:

python initialfile.py 1stdout.txt 2stderr.txt

or if you want standard out and standard error to go to the same file:

python initialfile.py 1output.txt 2output.txt

or if you don't want to see anything on standard error:

python initialfile.py 1output.txt 2/dev/null


As for windows, I'll test it now...

It turns out you can at least redirect the output to a file, I'm not
sure what it does with standard error or even if it exists or not.

python initialfile.py  output.txt

should work.


Hope it helps,

Cameron.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging output from python

2006-12-07 Thread Gabriel Genellina

At Thursday 7/12/2006 23:21, Cameron Walsh wrote:


 Here is my problem. I want to log everything displayed in the screen
 after I start the main python script. Things include unhandled
 exceptions , message from print statement and other sources.
 Basically, if it is displayed on the screen, I want to log it..

If it's on linux you can just redirect the screen output to a file:

python initialfile.py 1stdout.txt 2stderr.txt
[...]

As for windows, I'll test it now...

It turns out you can at least redirect the output to a file, I'm not
sure what it does with standard error or even if it exists or not.

python initialfile.py  output.txt


It's the same syntax as noted for linux above. 1 is the same as  alone.

If ALL the testing is done on a single program (that is, no os.system 
or spawn or subprocess...) then you could just replace sys.stdout and 
sys.stderr with another open file (or file-like) object.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Console logging/output for DocXMLRPCServer

2005-07-13 Thread sameer_deshpande
Hello,

I have written simple code using DocXMLRPCServer. How do I log method
name on the console after invoking registered
method on server. On the console it just prints message as [hostname -
date/time and POST /RPC2 HTTP/1.0 200 -]

code is:

from DocXMLRPCServer import DocXMLRPCServer

def Test(dummy):
print dummy
return 1


if __name__ == '__main__':
server = DocXMLRPCServer((, 8000, logRequests = 1))
server.register_function(Test)
server.serve_forever()

-

 import xmlrpclib
 s = xmlrpclib.Server(http://localhost:8000;)
 s.Test(Hello)

Output of console after invoking method Test is:

hostname - - [13/Jul/2005 13:28:04] POST /RPC2 HTTP/1.0 200 -


Thanks

Sameer

-- 
http://mail.python.org/mailman/listinfo/python-list