create log on android

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
pedrox
Posts: 992
Joined: Fri Mar 10, 2006 5:07 am
Location: Basque Country (Spain)
Contact:

create log on android

Post by pedrox » Sun Mar 17, 2019 3:33 pm

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: 1159
Joined: Tue Aug 30, 2016 6:19 pm
Contact:

Re: create log on android

Post by Ras » Sun Mar 17, 2019 9:15 pm

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: 433
Joined: Mon Apr 24, 2006 6:06 pm
Contact:

Re: create log on android

Post by Rémi Coulom » Mon Mar 18, 2019 7:47 pm

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: 992
Joined: Fri Mar 10, 2006 5:07 am
Location: Basque Country (Spain)
Contact:

Re: create log on android

Post by pedrox » Tue Mar 19, 2019 6:11 pm

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.

Post Reply