cashapp / zipline

Run Kotlin/JS libraries in Kotlin/JVM and Kotlin/Native programs
Apache License 2.0
2.04k stars 153 forks source link

Identifier 'console' undefined #123

Closed dennisdrew closed 2 years ago

dennisdrew commented 5 years ago

I get this error when attempting to do a simple console.log call.

After reading Duktape documentation, I see that it does not provide a console implementation. Is that true for duktape-android? If so, can we provide a console implementation?

JakeWharton commented 5 years ago

Seems fine. You can always delete it or reassign it to no-op. Want to send a PR?

ghost commented 5 years ago

You could also create a console implementation in java/kotlin and then bind it to the engine. It depends where you'd like console.log to go.

Shuijwan commented 4 years ago

you can implement console like this. @Keep interface Log { void log(String msg); void error(String msg); void info(String msg); void warn(String msg); void debug(String msg); }

Log log = new Log() { @Override @Keep public void log(String msg) { //your implementation }

        @Override
        @Keep
        public void error(String msg) {

        }

        @Override
        @Keep
        public void info(String msg) {
        }

        @Override
        @Keep
        public void warn(String msg) {

        }

        @Override
        @Keep
        public void debug(String msg) {

        }
    };

duktape.set("console", Log.class, log);
JakeWharton commented 2 years ago

We support console on HEAD and will be in the first Zipline releases.