logfile system on Android?

Previous topic - Next topic

spacefractal

I have today successfull compiled a little test app to work on my friends phone (not I dont have one my self, but should get such a table), but my still secret game do crash somewhere in the code.

I have not a clue if its does start of not, so I trying to create a little log system, so I can se what the app doing in the startup, so I better can se where it crash.

Howover, as I see Android is of course sandboxed, but its is possible to take the logfile created by OPENFILE out of the device in someway?

I guess the append to the apk file, or does its use a datafolder or such?

By now I use SaveLog$=PLATFORMINFO$("APPDATA")+"/Game_Runtime.log" when running in Android.

PS. I guess the best place is how to acces to a SDCARD directly.... Not sure how to detect those.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Slydog

I know that iOS devices have a system log somewhere that you can write to. (I've never used it)
You use 'STDOUT', such as I use in my LOG() function:
(I don't know if and or where Android logs messages however.)

Code (glbasic) Select
FUNCTION LOG: message$, add_linefeed% = TRUE, show_time% = TRUE
STATIC datetime% = -1 // Log timer
LOCAL elapsed# // How much time has elapsed since program start (or manual reset)
IF datetime < 0 THEN datetime = GETTIMERALL() // Initialize log timer if not already set
IF message$ = "RESET" THEN datetime = GETTIMERALL() // Manually reset log timer
elapsed = (GETTIMERALL() - datetime) / 1000.0
?IFDEF WIN32
//?IFDEF GLB_DEBUG
//?ENDIF
IF show_time = TRUE THEN DEBUG "[" + FORMAT$(8, 3, elapsed) + "] "
DEBUG message$
IF add_linefeed THEN DEBUG "\n"
?ELSE
INLINE
STDOUT(message_Str);
ENDINLINE
?ENDIF
ENDFUNCTION
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Quentin


Slydog

#3
Quote from: Quentin on 2011-Jul-29
perhaps the adb tool can help in this case?

http://developer.android.com/guide/developing/tools/adb.html

The following is from the above link, and what happens to 'STDOUT' calls:

QuoteViewing stdout and stderr

By default, the Android system sends stdout and stderr (System.out and System.err) output to /dev/null. In processes that run the Dalvik VM, you can have the system write a copy of the output to the log file. In this case, the system writes the messages to the log using the log tags stdout and stderr, both with priority I.

To route the output in this way, you stop a running emulator/device instance and then use the shell command setprop to enable the redirection of output. Here's how you do it:

$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start


The system retains this setting until you terminate the emulator/device instance. To use the setting as a default on the emulator/device instance, you can add an entry to /data/local.prop on the device.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

spacefractal

The only problem is not mine device, so I hope it can been done with a third party phone, without having the SDK... A least with the debugger version (which is only those that can install and work, which is fine).

The best place is simply write to the sdcard device where music, pictures etc is? If that is possible and allowed (I guess need to setup a another permission to the xml file)?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Slydog

Ya, ideally I guess you'd want to write to the SD card, so you can take it with you.

Or, you can use the 'NETSENDMSG' command to send it to a server, if you have one available.
Have a receiving PHP script that just passes the message through to a log file, which you can read via FTP or something.
Or read it directly in the web browser by typing in it's URL.

This could be useful for other people, for any platform.  (Include the device id or something to tell the devices apart).
That way you can install your game on multiple friend's devices, and have logging automatically keep track of problems at a central location.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad

I was thinking about a network based logging system too - it would be very useful (especially if log files aren't easily accessible).

You could send the data to a form on a website too...


spacefractal

I finally out why it crash, after some hours work got the Android emulator to work...

Its was a silly error with cases on the folder, which should have been small letters and not big letters. Typical Unix.

I did never got the log file system to work, but instead I used CLEARSCREEN so I could see where it did crash. Its did look like somewhere a old C64 game, hehe. but did found the error using that.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

stdout will be forwarded to the ADB log as an "i" info log.