Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Clearing Corona console log
Started by Appletreeman Jan 08 2019 01:49 AM

- - - - -
6 replies to this topic

Best Answer ojnab , 08 January 2019 - 06:41 AM

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'")

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 420 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 539 posts
  • Corona SDK

  Best Answer

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'")

  • Appletreeman and Alan PlantPot like this

[TOPIC: post.html]
#3

Yoger Games

[GLOBAL: userInfoPane.html]
Yoger Games
  • Contributor

  • 102 posts
  • Corona SDK

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

 

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



[TOPIC: post.html]
#4

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 882 posts
  • Corona SDK

 

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'")

 

 

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.



[TOPIC: post.html]
#5

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 420 posts
  • Corona SDK

@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.



[TOPIC: post.html]
#6

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 882 posts
  • Corona SDK

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.



[TOPIC: post.html]
#7

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 420 posts
  • Corona SDK

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




[topic_controls]
[/topic_controls]