PhilipsHue / flutter_reactive_ble

Flutter library that handles BLE operations for multiple devices.
https://developers.meethue.com/
Other
661 stars 321 forks source link

Add methods to disable logger completely (#708) #861

Open bobatsar opened 3 months ago

bobatsar commented 3 months ago

As described in #708 the string interpolation can use quite a lot of CPU time, even if the logger is set to LogLevel.none.

This PR allows to set the logger to null which then removes the string interpolations.

Taym95 commented 2 months ago

Thanks a lot for contributing, and sorry for closing it. I double-checked, and indeed it uses quite a lot of CPU time. Please update the example app and let's merge this one. It will be available in the next version.

bobatsar commented 2 months ago

Ok, I will have a look at the example app.

How should the behavior be in the example app? Logging completely disabled or how should I change it?

The example app still works as it is with the old behavior (_debugLogger is initialized to DebugLogger). To disable the logger (my PR) one simply has to call e.g.

final _ble = FlutterReactiveBle();
_ble.logger = null;
bobatsar commented 2 months ago

@Taym95 In my opinion the disabled logger should be the default (to make sure no performance is wasted in the logger) and only when enabling it manually it should be started.

Otherwise all users have to disable it to get the best performance.

This woul mean some more changes in the code and the example.

What is your preferred solution?

Taym95 commented 2 months ago

@Taym95 In my opinion the disabled logger should be the default (to make sure no performance is wasted in the logger) and only when enabling it manually it should be started.

Otherwise all users have to disable it to get the best performance.

This woul mean some more changes in the code and the example.

What is your preferred solution?

It makes sense, but some people are already using this. Functionality will stop working for them when the update happens