Possible to save the output to a file with timestamp ?

Possible to save the output to a file with timestamp ?

At the moment I've set the console to output to a log file. Would/Is it possible to include a timestamp in the output file ? e.g.

Current:

<path_to_dir>/console.log

Wanted:

<path_to_dir>/console-<date>.log

That way it would not override the previously executed run.

 

Regards,

Pontus

2 comments
Comment actions Permalink

Hi,

Unfortunately we don't have such feature.

Please feel free to submit a feature request about it to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY and let us know if you need any help.

0
Comment actions Permalink

I was able to work around this by creating a separate small "log_saver" program. That program simply checks a directory where "naked" logs might be found. If it finds any, it dresses them up. (That is, it renames them to include a filename + the date and time that the log file was last modified.)  Be sure to avoid including characters (such as the colon) which may not be allowed in filenames by your OS. Be sure this little Python program can end without any particular exit code. 

Now set this program to run within the configuration of your real python program(s).  Edit Configurations (under the Run menu) then in each Python program, scroll to the bottom of the Configurations to find the "Before Launch" section. Add your little log_saver program here. 

So for any given time, the naked log in the directory are the most current logs for that Python program. The next time one of your Python program runs, it will rename the naked log to include a timestamp using the log_saver program.  Then the real Python program will run and create a new naked log. 

 

1

Please sign in to leave a comment.