pcfens / RaspberryPi-AS3935

A basic library for working with the AS3935 that's connected to the Raspberry Pi.
Other
52 stars 24 forks source link

Output to file #26

Closed bucherrolf closed 7 years ago

bucherrolf commented 7 years ago

Has anyone found the right code for redirecting the "demo.py" script to a file. I'm looping around with writng to stdout stdin ev. piping or simply > to file.. I tested this with open("blitze.dat", "w") as f: sys.stdout = f for global redirecting the print. But the file is not open for printing

Any help would be appreciated

pcfens commented 7 years ago

Do you want to log lightning data only or everything that currently goes to stdout? The demo script was setup to demonstrate the library, so I didn't put a lot of thought into extending it for other uses, though I do have another project that pushes lighting data over the web.

You might consider replacing the print statements with logging statements and use Python's logging facility if that meets your needs.

bucherrolf commented 7 years ago

logging facility is the key. Many thanks for the link.. I guess this will help to solve my needs.