handle a log file.

  • Thread starter Zunbeltz Izaola
  • Start date
Z

Zunbeltz Izaola

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) |
 
P

Peter L Hansen

Zunbeltz said:
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
 
J

Josiah Carlson

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
 
Z

Zunbeltz Izaola

Peter L Hansen said:
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) |
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top