How to get the console.log("let's log something") messages after executing the js file?

Jun 4, 2014 at 2:34 PM
Hello!

At first, thank you for your work, ClearScript is awesome.

My question is: how to get the console.log("") messages after executing the js file? I created a host object and basically substituted the console object.
engine.AddHostObject("console", new ClearScriptLogger());
class ClearScriptLogger
{
     public void log(String message)
     {
        debug(message);        
     }

     public void debug(String message)
     {
         Debug.WriteLine(message);
     }
}
But this solution is kind of a hack. Any other solutions?
Coordinator
Jun 4, 2014 at 3:57 PM
Hello boli,

First, thanks for your positive feedback!

Regarding your question, the console object is not part of the JavaScript standard; it's part of the Web API. A ClearScript JavaScript engine by default has no console object, so you're not replacing anything. You're simply providing an API for scripts to call. Nothing wrong with that :)

Cheers!