diff --git a/example/example.dart b/example/example.dart index 482add8..85ac589 100644 --- a/example/example.dart +++ b/example/example.dart @@ -13,8 +13,7 @@ void main() async { var credentials = SpotifyApiCredentials(keyMap['id'], keyMap['secret']); var spotify = SpotifyApi(credentials); - spotify.enableLogging(true, loggingDetail: LoggingDetail.simple); - // spotify.loggingDetail = LoggingDetail.simple; + spotify.enableLogging(enable: true); print('\nExpannd shortened spotify link of https://spotify.link/hRkBrwub9xb'); var longLink = await spotify.expandLink('https://spotify.link/hRkBrwub9xb'); diff --git a/lib/src/spotify_base.dart b/lib/src/spotify_base.dart index 596c5f5..2b8df37 100644 --- a/lib/src/spotify_base.dart +++ b/lib/src/spotify_base.dart @@ -183,10 +183,12 @@ abstract class SpotifyApiBase { /// [enable]s logging of the requests and responses on the debug console. /// [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); + /// If required [logger] is also possible for e.g. saving logs into a file etc. + void enableLogging( + {required bool enable, + LoggingDetail loggingDetail = LoggingDetail.simple, + Logger? logger}) { + _spotifyClient.enableLogging = enable; _spotifyClient.loggingDetail = loggingDetail; _spotifyClient.logger = logger; } diff --git a/lib/src/spotify_client.dart b/lib/src/spotify_client.dart index 3364399..698ffe8 100644 --- a/lib/src/spotify_client.dart +++ b/lib/src/spotify_client.dart @@ -22,10 +22,8 @@ class SpotifyClient with http.BaseClient { bool _enableLogging = false; - /// [entable]s logging of the reuqests and responses with the Spotify-API. - void enableLogging(bool enable) { - _enableLogging = enable; - } + /// [enable]s logging of the reuqests and responses with the Spotify-API. + set enableLogging(enable) => _enableLogging = enable; late Logger _logger; set logger(value) { @@ -33,7 +31,7 @@ class SpotifyClient with http.BaseClient { if (!_enableLogging) { throw StateError('[enableLogging] must be set to [true]'); } - logger = value ?? Logger(); + _logger = value ?? Logger(); } LoggingDetail _detail = LoggingDetail.simple;