Clearing Corona console log

Hi guys,

Running Corona on OSX I know that if I bring focus to the console and press CMD+K it will clear the console window leaving it empty.

What I was wondering is if there is a way to do this from within a my app.  I’m currently using quite a lot of print statements for debugging purposes and it would be really nice to be able to have the log clear on each reload/scene change etc.  

Many thanks

You can try doing it with applescript

os.execute("osascript -e 'tell application \"CoronaConsole\" to activate'") os.execute("osascript -e 'tell application \"System Events\" to keystroke \"k\" using command down'")

Maybe plugin Logger can help you reduce the number of log messages ?

https://marketplace.coronalabs.com/corona-plugins/logger-structure-logging-using-channels

This is prefect, I never knew this was possible in the sim until now. Like an experienced plumber I’ve spent years clearing out logs by hand.

@ojnab - Brilliant & simple.  Thank you!

@Yoger Games - Didn’t know that plugin existed.  It’s a bit more than I need right now, but is very useful to know about for my next big project.

This also has a side effect of bringing the console window to the foreground. Does anyone know the command that would bring the simulator window to the front after clearing the log? 

It’s a minor issue, but annoying having to to do an extra click to set focus back onto the simulator every time I restart it.

I’ve tried this, but it causes the simulator to hang:

os.execute("osascript -e 'tell application \"CoronaConsole\" to activate'") os.execute("osascript -e 'tell application \"System Events\" to keystroke \"k\" using command down'") os.execute("osascript -e 'tell application \"Corona Simulator\" to activate'")

and also

os.execute("osascript -e 'tell application \"Corona Simulator\" to reopen'")

Any command that has “Corona Simulator” in it causes the simulator to hang.

I noticed that as well.   For now though I’m happy with the one click as it’s still less effort than click->CMD-K->click

You can try doing it with applescript

os.execute("osascript -e 'tell application \"CoronaConsole\" to activate'") os.execute("osascript -e 'tell application \"System Events\" to keystroke \"k\" using command down'")

Maybe plugin Logger can help you reduce the number of log messages ?

https://marketplace.coronalabs.com/corona-plugins/logger-structure-logging-using-channels

This is prefect, I never knew this was possible in the sim until now. Like an experienced plumber I’ve spent years clearing out logs by hand.

@ojnab - Brilliant & simple.  Thank you!

@Yoger Games - Didn’t know that plugin existed.  It’s a bit more than I need right now, but is very useful to know about for my next big project.

This also has a side effect of bringing the console window to the foreground. Does anyone know the command that would bring the simulator window to the front after clearing the log? 

It’s a minor issue, but annoying having to to do an extra click to set focus back onto the simulator every time I restart it.

I’ve tried this, but it causes the simulator to hang:

os.execute("osascript -e 'tell application \"CoronaConsole\" to activate'") os.execute("osascript -e 'tell application \"System Events\" to keystroke \"k\" using command down'") os.execute("osascript -e 'tell application \"Corona Simulator\" to activate'")

and also

os.execute("osascript -e 'tell application \"Corona Simulator\" to reopen'")

Any command that has “Corona Simulator” in it causes the simulator to hang.

I noticed that as well.   For now though I’m happy with the one click as it’s still less effort than click->CMD-K->click