add function 'qlog' for android logging (EQL5-Android only)
This commit is contained in:
parent
021b44a56e
commit
7b8aba492d
5 changed files with 35 additions and 0 deletions
|
|
@ -44,6 +44,7 @@
|
|||
"qload-c++"
|
||||
"qload-ui"
|
||||
"qlocal8bit"
|
||||
"qlog"
|
||||
"qmessage-box"
|
||||
"qmsg"
|
||||
"qnew"
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ void iniCLFunctions() {
|
|||
DEFUN ("%qload-c++", qload_cpp, 2)
|
||||
DEFUN ("qload-ui", qload_ui, 1)
|
||||
DEFUN ("qlocal8bit", qlocal8bit, 1)
|
||||
DEFUN ("qlog", qlog, 1)
|
||||
DEFUN ("%qnew-instance", qnew_instance2, 2)
|
||||
DEFUN ("%qobject-names", qobject_names2, 1)
|
||||
DEFUN ("qok", qok, 0)
|
||||
|
|
@ -2978,6 +2979,12 @@ cl_object qrun_in_gui_thread2(cl_object l_function_or_closure, cl_object l_block
|
|||
error_msg("QRUN-IN-GUI-THREAD", LIST1(l_function_or_closure));
|
||||
return Cnil; }
|
||||
|
||||
cl_object qlog(cl_object l_msg) {
|
||||
// for android logging only; see 'eql.cpp::logMessageHandler()'
|
||||
ecl_process_env()->nvalues = 1;
|
||||
qDebug() << toQString(l_msg);
|
||||
return Cnil; }
|
||||
|
||||
|
||||
|
||||
// *** special extensions ***
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ cl_object qinvoke_method2 (cl_object, cl_object, cl_object, cl_object);
|
|||
cl_object qload_cpp (cl_object, cl_object);
|
||||
cl_object qload_ui (cl_object);
|
||||
cl_object qlocal8bit (cl_object);
|
||||
cl_object qlog (cl_object);
|
||||
cl_object qmeta_enums ();
|
||||
cl_object qnew_instance2 (cl_object, cl_object);
|
||||
cl_object qobject_names2 (cl_object);
|
||||
|
|
|
|||
25
src/eql.cpp
25
src/eql.cpp
|
|
@ -13,7 +13,32 @@ extern "C" void ini_EQL(cl_object);
|
|||
|
||||
static const char* _argv_[] = {"EQL5"};
|
||||
|
||||
#ifdef COMPILE_ANDROID
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
static void logMessageHandler(QtMsgType, const QMessageLogContext& context, const QString& msg) {
|
||||
// for logging on android (see 'adb logcat')
|
||||
// examples:
|
||||
// Lisp: (qlog "message")
|
||||
// QML: console.log("message")
|
||||
QString report(msg);
|
||||
if(context.file && !QString(context.file).isEmpty()) {
|
||||
report += " in file ";
|
||||
report += QString(context.file);
|
||||
report += " line ";
|
||||
report += QString::number(context.line); }
|
||||
if(context.function && !QString(context.function).isEmpty()) {
|
||||
report += " function ";
|
||||
report += QString(context.function); }
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "[EQL5]", report.toLocal8Bit().constData()); }
|
||||
|
||||
#endif
|
||||
|
||||
EQL::EQL() : QObject() {
|
||||
#ifdef COMPILE_ANDROID
|
||||
qInstallMessageHandler(logMessageHandler); // see above
|
||||
#endif
|
||||
if(!cl_booted) {
|
||||
cl_boot(1, (char**)_argv_); }
|
||||
iniCLFunctions();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#:qload-c++
|
||||
#:qload-ui
|
||||
#:qlocal8bit
|
||||
#:qlog
|
||||
#:qmessage-box
|
||||
#:qmsg
|
||||
#:qnew
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue