Re: [Zope] Write log file from script

2005-10-10 Thread Chris Withers

Dave Kuhlman wrote:


Why not zLOG?  Look at:

Zope-2.8.1-home/lib/python/zLOG/__init__.py


Well, zLOG is hopefully going away some time soon ;-)

You should really be using the python logging module, for which zLOG is 
now just a facade:


import logging
logger = logging.getLogger('event.whatever')

logger.info('Argh! Help, the world with end in %i seconds',end_of_time)

I'm just writing a proposal to make this available in untrusted code 
such as Script (Python)'s, but in the meantime, you can use an external 
method:


import logging

logger = logging.getLogger('event.myapplogger')

def log(self,level,message,*args,exc_info=False):

logger.log(getattr(logging,level),
   message,
   *args,
   exc_info = exc_info

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-08 Thread Dieter Maurer
Brian Sullivan wrote at 2005-10-7 11:42 -0400:
I am looking for a simple strategy to write a debug log file from a python
script.

In an External Method (trusted code), you can write files
as usual in Python. An elementary log function could be:

   def log(msg):
 open(LOGFILE, a).write(msg)


You cannot use open in untrusted code (for obvious reasons).

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Write log file from script

2005-10-07 Thread Brian Sullivan
I am looking for a simple strategy to write a debug log file from a python script.

I used to have such a beast but somewhere in a shuffle it got lost -- and my brain seems to be dead this morning trying to figure it out.

Anybody out there have something like this or a url explaining how to do it?
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Jonathan



How about creating a string or list, then appending 
your debug info to the string/list, then returning the string/list to the 
calling routine which then displays the string/list?

Jonathan

  - Original Message - 
  From: 
  Brian 
  Sullivan 
  To: zope@zope.org 
  Sent: Friday, October 07, 2005 11:42 
  AM
  Subject: [Zope] Write log file from 
  script
  
  I am looking for a simple strategy to write a debug log file from a 
  python script.
  
  I used to have such a beast but somewhere in a shuffle it got lost -- and 
  my brain seems to be dead this morning trying to figure it out.
  
  Anybody out there have something like this or a url explaining how to do 
  it?
  
  

  ___Zope maillist 
  - 
  Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** 
  No cross posts or HTML encoding! **(Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev 
  )
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Dennis Allison

Depends upon what you want to do and how much access  you have.  For 
debugging purposes I often use an external procedure

def debugWindow( data ):
   fd = open('/tmp/debugWindow,'a')
   fd.write( str(data))
   fd.close()

and look at the output with 

   tail -f /tmp/debugWindow

Or, you can use the same approach to write to syslog using the Python 
logging module

Or you can piggyback into the Zope logging mechanism--see the sources for 
that exercise.

I find the external procedure approach to be useful in its simplicity



On Fri, 7 Oct 2005, Brian Sullivan wrote:

 I am looking for a simple strategy to write a debug log file from a python
 script.
  I used to have such a beast but somewhere in a shuffle it got lost -- and
 my brain seems to be dead this morning trying to figure it out.
  Anybody out there have something like this or a url explaining how to do
 it?
 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Brian Sullivan

On 10/7/05, Dennis Allison [EMAIL PROTECTED] wrote:
Depends upon what you want to do and how much accessyou have.Fordebugging purposes I often use an external procedure
def debugWindow( data ):fd = open('/tmp/debugWindow,'a')fd.write( str(data))fd.close()and look at the output withtail -f /tmp/debugWindowOr, you can use the same approach to write to syslog using the Python
logging moduleOr you can piggyback into the Zope logging mechanism--see the sources forthat exercise.I find the external procedure approach to be useful in its simplicity

OK -- thanks to those that replied (many with a similar solution).

I do have access to the server (Win2000 in my case) so I can pretty well do anything I want.

It comes back now -- I did something like that but then called it through a gateway Python script that allowed me to turn off all logging in one spot easily (by modifying the script) in case I wanted to leave the debug statements there temporarily and not incur the expense of a huge log file.

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Dave Kuhlman
On Fri, Oct 07, 2005 at 11:42:16AM -0400, Brian Sullivan wrote:
 I am looking for a simple strategy to write a debug log file from a python
 script.
  I used to have such a beast but somewhere in a shuffle it got lost -- and
 my brain seems to be dead this morning trying to figure it out.
  Anybody out there have something like this or a url explaining how to do
 it?

Why not zLOG?  Look at:

Zope-2.8.1-home/lib/python/zLOG/__init__.py

There are lots of examples of the use of the LOG function, defined
in that file, scattered throughout the Zope code.

And, your_instance/etc/zope.conf enables you to control the
logging output.

Dave

-- 
Dave Kuhlman
http://www.rexx.com/~dkuhlman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Tino Wildenhain
Am Freitag, den 07.10.2005, 09:03 -0700 schrieb Dennis Allison:
 Depends upon what you want to do and how much access  you have.  For 
 debugging purposes I often use an external procedure
 
 def debugWindow( data ):
fd = open('/tmp/debugWindow,'a')
fd.write( str(data))
fd.close()


Actually this is a bit dangerous if you dont lock
the file.

import zLOG

def log(self,message):
zLOG.LOG(PythonScript, zLOG.INFO, message)


as external method should be enough.

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Brian Sullivan

On 10/7/05, Tino Wildenhain [EMAIL PROTECTED] wrote:
Am Freitag, den 07.10.2005, 09:03 -0700 schrieb Dennis Allison: Depends upon what you want to do and how much accessyou have.For
 debugging purposes I often use an external procedure def debugWindow( data ):fd = open('/tmp/debugWindow,'a')fd.write( str(data))fd.close()Actually this is a bit dangerous if you dont lock
the file.import zLOGdef log(self,message): zLOG.LOG(PythonScript, zLOG.INFO, message)as external method should be enough.


And where does this log information end up?
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Dennis Allison

We are running on a linux host.  The file information ends upon 
in the local file system in the /tmp directory.


On Fri, 7 Oct 2005, Brian Sullivan wrote:

 On 10/7/05, Tino Wildenhain [EMAIL PROTECTED] wrote:
 
  Am Freitag, den 07.10.2005, 09:03 -0700 schrieb Dennis Allison:
   Depends upon what you want to do and how much access you have. For
   debugging purposes I often use an external procedure
  
   def debugWindow( data ):
   fd = open('/tmp/debugWindow,'a')
   fd.write( str(data))
   fd.close()
 
 
  Actually this is a bit dangerous if you dont lock
  the file.
 
  import zLOG
 
  def log(self,message):
  zLOG.LOG(PythonScript, zLOG.INFO http://zLOG.INFO, message)
 
 
  as external method should be enough.
 
   And where does this log information end up?
 

-- 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Write log file from script

2005-10-07 Thread Brian Sullivan

On 10/7/05, Dennis Allison [EMAIL PROTECTED] wrote:
We are running on a linux host.The file information ends uponin the local file system in the /tmp directory.
  import zLOG   def log(self,message):  zLOG.LOG(PythonScript, zLOG.INFO http://zLOG.INFO, message)
as external method should be enough.  And where does this log information end up?--


I was referring to the zLOG info. Where does it go?
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )