Giter Club home page Giter Club logo

Comments (7)

paddybyers avatar paddybyers commented on June 15, 2024

Are you expecting the console.log to come out into the browser log or the server log?
The "Hello world" is the document returned by the server to the browser's http request, and so the browser will display this page. There's no javascript running in the returned page, so you won't see anything in the browser's javascript console.

The "console.error" statement is running on the server, so perhaps you're expecting that to come out into the logcat of the server. Unfortunately this doesn't happen automatically - console.error goes to the stderr of the application process, but by default Android just sends this to /dev/null.

You can get Android to redirect stderr and stdout to logcat if you do the following in an Android shell:

echo "log.redirect-stdio=true" > /data/local.prop

Hope this helps

from anode.

hanyu-natsu avatar hanyu-natsu commented on June 15, 2024

thank you for your help !

I tried doing "setprop log.redirect-stdio true" in the android shell, and I have this line [log.redirect-stdio]: [true] when I run getprop.

I think I shall have the err message in my Logcat when I start the server, but nothing, here is the log :

09-25 15:46:27.235: I/ActivityManager(1647): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher u=0} from pid 1647
09-25 15:46:28.712: D/dalvikvm(1818): WAIT_FOR_CONCURRENT_GC blocked 0ms
09-25 15:46:28.767: D/dalvikvm(1818): GC_EXPLICIT freed 125K, 20% free 9015K/11207K, paused 3ms+9ms, total 51ms
09-25 15:46:30.017: I/ActivityManager(1647): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.meshpoint.anode/.AnodeActivity u=0} from pid 1818
09-25 15:46:30.118: D/dalvikvm(1647): GC_CONCURRENT freed 826K, 10% free 9440K/10439K, paused 5ms+0ms, total 90ms
09-25 15:46:30.134: D/dalvikvm(1647): WAIT_FOR_CONCURRENT_GC blocked 79ms
09-25 15:46:30.181: D/dalvikvm(2427): Not late-enabling CheckJNI (already on)
09-25 15:46:30.181: D/dalvikvm(1391): WAIT_FOR_CONCURRENT_GC blocked 0ms
09-25 15:46:30.181: I/ActivityManager(1647): Start proc org.meshpoint.anode for activity org.meshpoint.anode/.AnodeActivity: pid=2427 uid=10048 gids={3003, 1015, 3002, 3001, 1028}
09-25 15:46:30.243: D/dalvikvm(1391): GC_EXPLICIT freed 38K, 5% free 5984K/6275K, paused 3ms+5ms, total 62ms
09-25 15:46:30.243: D/dalvikvm(1391): WAIT_FOR_CONCURRENT_GC blocked 0ms
09-25 15:46:30.251: W/ActivityThread(2427): Application org.meshpoint.anode can be debugged on port 8100...
09-25 15:46:30.306: D/dalvikvm(1391): GC_EXPLICIT freed <1K, 5% free 5984K/6275K, paused 4ms+3ms, total 53ms
09-25 15:46:30.306: D/dalvikvm(1391): WAIT_FOR_CONCURRENT_GC blocked 0ms
09-25 15:46:30.337: D/dalvikvm(1391): GC_EXPLICIT freed <1K, 5% free 5984K/6275K, paused 2ms+2ms, total 37ms
09-25 15:46:30.454: V/TabletStatusBar(1737): setLightsOn(true)
09-25 15:46:30.548: I/ActivityManager(1647): Displayed org.meshpoint.anode/.AnodeActivity: +404ms
09-25 15:46:42.556: E/BinaryDictionaryGetter(1783): Could not find a dictionary pack
09-25 15:46:42.556: E/ActivityThread(1783): Failed to find provider info for com.android.inputmethod.latin.dictionarypack
09-25 15:46:42.610: D/dalvikvm(1783): GC_CONCURRENT freed 258K, 6% free 6427K/6791K, paused 17ms+0ms, total 59ms
09-25 15:46:52.470: V/anode::RuntimeNative(2427): extractLib: library up to date
09-25 15:46:52.470: D/dalvikvm(2427): Trying to load lib /data/data/org.meshpoint.anode/app/libjninode.so 0x415d77f0
09-25 15:46:52.478: D/dalvikvm(2427): Added shared lib /data/data/org.meshpoint.anode/app/libjninode.so 0x415d77f0
09-25 15:46:52.478: D/dalvikvm(2427): No JNI_OnLoad found in /data/data/org.meshpoint.anode/app/libjninode.so 0x415d77f0, skipping init
09-25 15:46:52.478: V/anode::RuntimeNative(2427): extractLib: library up to date
09-25 15:46:52.478: D/dalvikvm(2427): Trying to load lib /data/data/org.meshpoint.anode/node_modules/bridge.node 0x415d77f0
09-25 15:46:52.493: D/dalvikvm(2427): Added shared lib /data/data/org.meshpoint.anode/node_modules/bridge.node 0x415d77f0
09-25 15:46:52.493: D/dalvikvm(2427): No JNI_OnLoad found in /data/data/org.meshpoint.anode/node_modules/bridge.node 0x415d77f0, skipping init
09-25 15:46:52.493: V/anode::RuntimeNative(2427): init: loaded libraries: modulePath = /data/data/org.meshpoint.anode/node_modules
09-25 15:46:52.493: V/libjninode(2427): Java_org_meshpoint_anode_RuntimeNative_nodeInit: ent
09-25 15:46:52.493: V/libjninode(2427): getNativeArgs: ent
09-25 15:46:52.493: V/libjninode(2427): getNativeArgs: ret 1
09-25 15:46:52.509: V/libjninode(2427): Java_org_meshpoint_anode_RuntimeNative_nodeInit: ret
09-25 15:46:52.509: V/libjninode(2427): Java_org_meshpoint_anode_RuntimeNative_create ent
09-25 15:46:52.509: V/libjninode(2427): Java_org_meshpoint_anode_RuntimeNative_create ret
09-25 15:46:52.509: V/anode::Isolate(2427): Isolate.run(): setting context
09-25 15:46:52.509: D/dalvikvm(2427): Trying to load lib null/bridge.node 0x415d77f0
09-25 15:46:52.509: D/dalvikvm(2427): Added shared lib null/bridge.node 0x415d77f0
09-25 15:46:52.509: D/dalvikvm(2427): No JNI_OnLoad found in null/bridge.node 0x415d77f0, skipping init
09-25 15:46:52.509: V/bridge-core(2427): Java_org_meshpoint_anode_bridge_BridgeNative_setContext: ent
09-25 15:46:52.509: V/bridge-core(2427): Env::setupEnv(): ent
09-25 15:46:52.509: V/bridge-core(2427): Env::initProcess(): ent
09-25 15:46:52.509: V/bridge-core(2427): Env::initProcess(): ret
09-25 15:46:52.509: V/bridge-core(2427): Env::initThread(): ent
09-25 15:46:52.509: V/bridge-core(2427): Env::initThread(): ret
09-25 15:46:52.509: V/bridge-core(2427): Env::setupEnv(): ret
09-25 15:46:52.509: V/bridge-core(2427): Java_org_meshpoint_anode_bridge_BridgeNative_setContext: ret
09-25 15:46:52.509: V/anode::Isolate(2427): Isolate.run(): set context
09-25 15:46:52.509: V/libjninode(2427): Java_org_meshpoint_anode_RuntimeNative_start: ent
09-25 15:46:52.509: V/libjninode(2427): getNativeArgs: ent
09-25 15:46:52.509: V/libjninode(2427): getNativeArgs: ret 2

from anode.

paddybyers avatar paddybyers commented on June 15, 2024

Perhaps that mechanism for setting the redirect property works only on phones and isn't enabled on your development board.

Can you try writing to a file and confirm you can see the output there?

I'm working on a new console object that will be a native node module that will write directly to logcat but maybe writing to a file will do what you need in the short term.

from anode.

hanyu-natsu avatar hanyu-natsu commented on June 15, 2024

I tried outputting to a file, this works well using 'fs',

But for the stdio, I have these messages in my logcat :

09-27 11:17:30.945: D/AndroidRuntime(2622): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-27 11:17:30.945: D/AndroidRuntime(2622): CheckJNI is ON
09-27 11:17:30.960: D/dalvikvm(2622): Trying to load lib libjavacore.so 0x0
09-27 11:17:30.960: D/dalvikvm(2622): Added shared lib libjavacore.so 0x0
09-27 11:17:30.984: D/dalvikvm(2622): Trying to load lib libnativehelper.so 0x0
09-27 11:17:30.984: D/dalvikvm(2622): Added shared lib libnativehelper.so 0x0
09-27 11:17:31.312: I/ethernet(2622): Loading ethernet jni class
09-27 11:17:31.351: D/AndroidRuntime(2622): Calling main entry com.android.commands.am.Am
09-27 11:17:31.351: I/stdout(2622): Broadcasting: Intent { act=org.meshpoint.anode.START (has extras) }
09-27 11:17:31.367: I/stdout(2622): Broadcast completed: result=0
09-27 11:17:31.367: D/AndroidRuntime(2622): Shutting down VM
09-27 11:17:31.367: I/AndroidRuntime(2622): NOTE: attach of thread 'Binder_3' failed
09-27 11:17:31.367: D/dalvikvm(2622): GC_CONCURRENT freed 102K, 81% free 494K/2560K, paused 0ms+0ms, total 2ms
09-27 11:17:31.367: D/dalvikvm(2622): Debugger has detached; object registry had 1 entries
09-27 11:17:31.367: D/dalvikvm(2622): Joining stdio converter...
09-27 11:17:31.367: I/stdout(2622): Shutting down
09-27 11:17:31.367: V/libjninode(2521): Java_org_meshpoint_anode_RuntimeNative_create ent
09-27 11:17:31.367: V/libjninode(2521): Java_org_meshpoint_anode_RuntimeNative_create ret
09-27 11:17:31.375: V/anode::Isolate(2521): Isolate.run(): setting context
09-27 11:17:31.375: V/bridge-core(2521): Java_org_meshpoint_anode_bridge_BridgeNative_setContext: ent
09-27 11:17:31.375: V/bridge-core(2521): Env::setupEnv(): ent
09-27 11:17:31.375: V/bridge-core(2521): Env::initThread(): ent
09-27 11:17:31.375: V/bridge-core(2521): Env::initThread(): ret
09-27 11:17:31.375: V/bridge-core(2521): Env::setupEnv(): ret
09-27 11:17:31.375: V/bridge-core(2521): Java_org_meshpoint_anode_bridge_BridgeNative_setContext: ret
09-27 11:17:31.375: V/anode::Isolate(2521): Isolate.run(): set context
09-27 11:17:31.375: V/libjninode(2521): Java_org_meshpoint_anode_RuntimeNative_start: ent
09-27 11:17:31.375: V/libjninode(2521): getNativeArgs: ent
09-27 11:17:31.375: V/libjninode(2521): getNativeArgs: ret 2
09-27 11:17:31.710: V/libjninode(2521): Java_org_meshpoint_anode_RuntimeNative_start: ret 1

I have run my javascript with adb shell am broadcast -a org.meshpoint.anode.START -e cmdline /data/tmp/hello.js,
and I got the roadcasting: Intent { act=org.meshpoint.anode.START (has extras) } and Broadcast completed: result=0 in my logcat.

The problem seems to be in these lines :
09-27 11:17:31.367: D/AndroidRuntime(2622): Shutting down VM
09-27 11:17:31.367: I/AndroidRuntime(2622): NOTE: attach of thread 'Binder_3' failed
09-27 11:17:31.367: D/dalvikvm(2622): Debugger has detached; object registry had 1 entries
09-27 11:17:31.367: D/dalvikvm(2622): Joining stdio converter...
09-27 11:17:31.367: I/stdout(2622): Shutting down

I don't understand what AndroidRuntime was trying to do with the thread 'Binder_3'...these messages weren't there if I don't enable the log.redirect-stdio.

from anode.

hanyu-natsu avatar hanyu-natsu commented on June 15, 2024

After working on this feature last week, I have written a native module enabling logs to logcat on C++, and I modified the console.js so that for the android system, the console will use my methods to write logs.

I insert the native module and his head into the node src, and I changed this file : <node_extensions.h> to register my module.

from anode.

paddybyers avatar paddybyers commented on June 15, 2024

ok, that sounds interesting. Are you able to share the code?

from anode.

hanyu-natsu avatar hanyu-natsu commented on June 15, 2024

I did the pull request to your node repo v0.6-android.

from anode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.