Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

FixAndroidLogger

Fixes the FireMonkey logging service so that adb logcat can be used to filter the logs

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

FixAndroidLogger

This app shows how using the FMX.Platform.Logger.Android.Fix unit, you can change the tag used by FireMonkey so that you can use adb logcat to properly filter your logs for debugging.

In order to use it, all you have to do is include the FMX.Platform.Logger.Android.Fix unit in your project file.

Quick steps to use it

  • Include or add FMX.Platform.Logger.Android.Fix in your project file.
  • Include FMX.Platform.Logger.Android.Fix in the uses clause.
  • Include the following code in when logging:
delphi
var LLogService: IFMXLoggingService;
var LLogPriority: IFMXTagPriority;
if TPlatformServices.Current.SupportsPlatformService(IFMXLoggingService, LLogService) and
    Supports(LLogService, IFMXTagPriority, LLogPriority) then 
    begin
      LLogPriority.i('TagName', 'LogMessage');
    end;

adb logcat -s TagName:*

Demo

See the code in for how to use it.

FMX app Console

Once you have clicked on the Change Tag button, all your logs will be tagged with that name.

You can also have priority tags as well, so your tags can have debug, error, info or verbose priority.

To filter the tags using adb logcat, simply use the command

pascal
adb logcat -s MyAppName

where MyAppName is the tag name you have chosen to use.

Hope this helps with your debugging.

Enjoy,
Chee-Wee Chua,
Singapore.