Skip to content

Commit

Permalink
adds better signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
hayribakici committed Jul 13, 2024
1 parent 275f680 commit b0ee94f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 6 additions & 4 deletions lib/src/spotify_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 3 additions & 5 deletions lib/src/spotify_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ 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) {
// don't allow to initialize a Logger when logging is disabled.
if (!_enableLogging) {
throw StateError('[enableLogging] must be set to [true]');
}
logger = value ?? Logger();
_logger = value ?? Logger();
}

LoggingDetail _detail = LoggingDetail.simple;
Expand Down

0 comments on commit b0ee94f

Please sign in to comment.