Log Output
You can output messages to the Content Studio log file from side panel UI components. The following example shows the HTML for a side panel component that is very similar to the "Hello world" example in Creating Browser UIs, but instead of displaying a message dialog, it sends a message to the Content Studio log file:
<!DOCTYPE html> <html> <head> <title>Log test</title> <script type="text/javascript"> function log(message) { if (window.studioConsole) { // when running in Content Studio use this window.studioConsole.log(message); } else { // when running in a browser use this console.log(message); } } </script> </head> <body> <input type="button" value="Print Log" onclick="log('This is a test message from Javascript')" /> </body> </html>
As with the example in
Creating Browser UIs, you can load
this HTML into a
Content Studio
side panel as follows (assuming it is stored as
test-log.html
on your local machine, and is served
by a web server):
var cs = require('content-studio'); var mypanel = 'http://example.com/studio/sidepanel/test-log'; var browserui; cs.on('panel-init', function(panelcontrol) { if (panelcontrol.uri == mypanel) { browserui = panelcontrol.show('browser'); } }); cs.createPanel(mypanel, '&Test log', 'shift F10'); browserui.uri = "http://localhost:8080/test-log.html";
Note that the logging code in test-log.html
does
not need to be executed via
scriptExecutor.executeScript()
.
You will find the
Content Studio
log file in a subfolder of your PC's TEMP folder called
com.escenic.studio/log
. The file itself is called
Studio
n.log
.
The messages output to the
Content Studio
log file are information messages, so they will only actually be
logged if your logging configuration is set up correctly. To enable
logging of these messages, hold down the Ctrl
key, select View >
Debug > Logging
Configuration from the
Content Studio
main menu and set the logging level to INFO
.