Created
July 30, 2023 00:00
-
-
Save DelphiWorlds/352df313c06f1f816ffa30b9492563de to your computer and use it in GitHub Desktop.
Using the Util.Log class from Android to emit log statements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses | |
Androidapi.JNIBridge, Androidapi.JNI.JavaTypes, Androidapi.Helpers; | |
type | |
Jutil_LogClass = interface(JObjectClass) | |
['{62108FE8-1DBB-4C4F-A0C7-35D12BD116DC}'] | |
{class} function _GetASSERT: Integer; cdecl; | |
{class} function _GetDEBUG: Integer; cdecl; | |
{class} function _GetERROR: Integer; cdecl; | |
{class} function _GetINFO: Integer; cdecl; | |
{class} function _GetVERBOSE: Integer; cdecl; | |
{class} function _GetWARN: Integer; cdecl; | |
{class} function d(tag: JString; msg: JString): Integer; cdecl; overload; | |
{class} function d(tag: JString; msg: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function e(tag: JString; msg: JString): Integer; cdecl; overload; | |
{class} function e(tag: JString; msg: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function getStackTraceString(tr: JThrowable): JString; cdecl; | |
{class} function i(tag: JString; msg: JString): Integer; cdecl; overload; | |
{class} function i(tag: JString; msg: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function isLoggable(tag: JString; level: Integer): Boolean; cdecl; | |
{class} function println(priority: Integer; tag: JString; msg: JString): Integer; cdecl; | |
{class} function v(tag: JString; msg: JString): Integer; cdecl; overload; | |
{class} function v(tag: JString; msg: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function w(tag: JString; msg: JString): Integer; cdecl; overload; | |
{class} function w(tag: JString; msg: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function w(tag: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function wtf(tag: JString; msg: JString): Integer; cdecl; overload; | |
{class} function wtf(tag: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} function wtf(tag: JString; msg: JString; tr: JThrowable): Integer; cdecl; overload; | |
{class} property ASSERT: Integer read _GetASSERT; | |
{class} property DEBUG: Integer read _GetDEBUG; | |
{class} property ERROR: Integer read _GetERROR; | |
{class} property INFO: Integer read _GetINFO; | |
{class} property VERBOSE: Integer read _GetVERBOSE; | |
{class} property WARN: Integer read _GetWARN; | |
end; | |
[JavaSignature('android/util/Log')] | |
Jutil_Log = interface(JObject) | |
['{6A5EC34E-CB76-4AB0-A11D-7CCB3B40C571}'] | |
end; | |
TJutil_Log = class(TJavaGenericImport<Jutil_LogClass, Jutil_Log>) end; | |
procedure LogDebug(const ATag, AMsg: string); | |
begin | |
TJutil_Log.JavaClass.d(StringToJString(ATag), StringToJString(AMsg)); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment