diff --git a/example/example.dart b/example/example.dart index 89d5d85..482add8 100644 --- a/example/example.dart +++ b/example/example.dart @@ -13,7 +13,7 @@ void main() async { var credentials = SpotifyApiCredentials(keyMap['id'], keyMap['secret']); var spotify = SpotifyApi(credentials); - spotify.enableDebugMode(true, LoggingDetail.simple); + spotify.enableLogging(true, loggingDetail: LoggingDetail.simple); // spotify.loggingDetail = LoggingDetail.simple; print('\nExpannd shortened spotify link of https://spotify.link/hRkBrwub9xb'); diff --git a/lib/src/spotify_base.dart b/lib/src/spotify_base.dart index 22f98b4..ac29429 100644 --- a/lib/src/spotify_base.dart +++ b/lib/src/spotify_base.dart @@ -181,11 +181,12 @@ abstract class SpotifyApiBase { } /// [enable]s logging of the requests and responses on the debug console. - /// Use [loggingDetail] to control how much should be logged. Default's set - /// to [LoggingDetail.simple]. - void enableDebugMode(bool enable, - [LoggingDetail loggingDetail = LoggingDetail.simple]) { - _spotifyClient.enableLogging = enable; + /// [loggingDetail] controls the logging verbosity. Default's set + /// to [LoggingDetail.simple]. + /// Use own [logger] is also possible for e.g. saving logs into a file etc. + void enableLogging(bool enable, + {LoggingDetail loggingDetail = LoggingDetail.simple, Logger? logger}) { + _spotifyClient.enableLogging(enable, logger: logger); _spotifyClient.logginDetail = loggingDetail; } diff --git a/lib/src/spotify_client.dart b/lib/src/spotify_client.dart index a76045b..7a3512d 100644 --- a/lib/src/spotify_client.dart +++ b/lib/src/spotify_client.dart @@ -20,11 +20,13 @@ part of '../spotify.dart'; class SpotifyClient with http.BaseClient { final FutureOr _inner; - final Logger _logger = Logger(); + late Logger _logger; bool _enableLogging = false; - get enableLogging => _enableLogging; - set enableLogging(value) => _enableLogging = value; + void enableLogging(bool enable, {Logger? logger}){ + _enableLogging = enable; + _logger = logger ?? Logger(); + } LoggingDetail _detail = LoggingDetail.full; get loggingDetail => _detail;