Skip to content

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

Notifications You must be signed in to change notification settings

chuacw/FixAndroidLogger

Repository files navigation

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:
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 FixAndroudLoggerDemoImpl.pas 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.

Demo

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

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.

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages