create log on android

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
pedrox
Posts: 1056
Joined: Fri Mar 10, 2006 6:07 am
Location: Basque Country (Spain)

create log on android

Post by pedrox »

In my engine I have created a function that prints a log file, the log file is created in the same folder in which the engine is located. Everything is working correctly.

Where I really want to try this log is about a gui on android, I have tried to create a file in the internal memory or the sd card giving it a full path because I think that in android it is necessary to specify complete paths. But the file is not created. I believe that I do not have writing permission.

I've only found information for java. Is it possible to do it with C language ?, the engines in android use log?

Thx
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: create log on android

Post by Ras »

If the directory the engine is in doesn't allow write access, then you can't create files there. This behaviour is the same under any Linux, not just Android. So the first thing is checking what the file permissions for this directory are.
Rasmus Althoff
https://www.ct800.net
Rémi Coulom
Posts: 438
Joined: Mon Apr 24, 2006 8:06 pm

Re: create log on android

Post by Rémi Coulom »

Is your engine compiled with the NDK?

The Android way of writing logs is to use the log native API:
https://developer.android.com/ndk/refer ... up/logging

I have code like this in my program:

Code: Select all

#ifdef __ANDROID__
#include <android/log.h>
#define LOG(x) do {\
 std::ostringstream oss;\
 oss << x;\
 __android_log_write(ANDROID_LOG_DEBUG, "my_program", oss.str().c_str());\
} while(false)
#endif
User avatar
pedrox
Posts: 1056
Joined: Fri Mar 10, 2006 6:07 am
Location: Basque Country (Spain)

Re: create log on android

Post by pedrox »

I use CodeSourcery ARM on Windows to compile the engine, maybe I should think about using the NDK since CodeSourcery is no longer free and I'm not sure if continued for Android.