Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > handle a log file.

Reply
Thread Tools

handle a log file.

 
 
Zunbeltz Izaola
Guest
Posts: n/a
 
      10-07-2004

Hi,

I've a GUI program (wxPython) that comunicates with a machine with UDP
sockets. Every sended socket is writted to file for inspection if
there is problem. What ocurs is that sometimes the file grows to much
(32Mb) and the program has problems to manage it. Is any way to
control the size of the file?

Thanks in advance

Zunbeltz

--
Zunbeltz Izaola Azkona | wmbizazz at lg dot ehu
dotes
Materia Kondentsatuaren Fisika Saila |
Zientzia eta Teknologia Fakultatea | Phone: 34946015326
Euskal Herriko Unibertsitatea |
PK 644 | Fax: 34 944648500
48080 Bilbo (SPAIN) |
 
Reply With Quote
 
 
 
 
Peter L Hansen
Guest
Posts: n/a
 
      10-07-2004
Zunbeltz Izaola wrote:
> I've a GUI program (wxPython) that comunicates with a machine with UDP
> sockets. Every sended socket is writted to file for inspection if
> there is problem. What ocurs is that sometimes the file grows to much
> (32Mb) and the program has problems to manage it. Is any way to
> control the size of the file?


Use the standard logging module. It provides the capability for
an automatically "rotating" log file which will handle rolling
over and deleting/renaming the previous file automatically.

You may need to write your own formatter, depending on the
nature of your log entries...
-Peter
 
Reply With Quote
 
 
 
 
Josiah Carlson
Guest
Posts: n/a
 
      10-07-2004

> I've a GUI program (wxPython) that comunicates with a machine with UDP
> sockets. Every sended socket is writted to file for inspection if
> there is problem. What ocurs is that sometimes the file grows to much
> (32Mb) and the program has problems to manage it. Is any way to
> control the size of the file?


if f.tell() > 2**25:
print "my file is to big"
fn = f.name
f.close()
#destroy the logfile
f = open(fn, 'w')

Probably not precisely what you want, but it will "control the size of
the file".

- Josiah

 
Reply With Quote
 
Zunbeltz Izaola
Guest
Posts: n/a
 
      10-08-2004
Peter L Hansen <(E-Mail Removed)> writes:

> Zunbeltz Izaola wrote:
> > I've a GUI program (wxPython) that comunicates with a machine with UDP
> > sockets. Every sended socket is writted to file for inspection if
> > there is problem. What ocurs is that sometimes the file grows to much
> > (32Mb) and the program has problems to manage it. Is any way to
> > control the size of the file?

>
> Use the standard logging module. It provides the capability for
> an automatically "rotating" log file which will handle rolling
> over and deleting/renaming the previous file automatically.
>
> You may need to write your own formatter, depending on the
> nature of your log entries...
> -Peter


Thanks to all for the response. I have use RotatingFileHandler and I
think it works smoothly.
Thaks for the point

Zunbetlz

--
Zunbeltz Izaola Azkona | wmbizazz at lg dot ehu
dotes
Materia Kondentsatuaren Fisika Saila |
Zientzia eta Teknologia Fakultatea | Phone: 34946015326
Euskal Herriko Unibertsitatea |
PK 644 | Fax: 34 944648500
48080 Bilbo (SPAIN) |
 
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
Package to handle table text render (handle space or tab betweenthe columns) ? =?ISO-8859-1?Q?KLEIN_St=E9phane?= Python 3 10-06-2006 08:46 AM
Passing a log handle to a module? Help needed with logging module and rh0dium Python 2 08-04-2005 02:27 PM
Possible to handle web requests without an ASPX page? i.e. have DLL handle request. jdlwright@shaw.ca ASP .Net 2 05-31-2005 05:42 PM
how to handle command line output(not terminal handle) Leon Python 2 11-04-2004 05:16 AM
File Handle Reading Blues: Rereading a File Handle for Input Dietrich Perl 1 07-22-2004 10:02 AM



Advertisments