@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
66import 'package:flutter_cache_manager/flutter_cache_manager.dart' ;
77import 'package:flutter_cache_manager/src/cache_managers/base_cache_manager.dart' ;
88import 'package:flutter_cache_manager/src/cache_store.dart' ;
9+ import 'package:flutter_cache_manager/src/logger.dart' ;
910import 'package:flutter_cache_manager/src/result/download_progress.dart' ;
1011import 'package:flutter_cache_manager/src/result/file_info.dart' ;
1112import 'package:flutter_cache_manager/src/result/file_response.dart' ;
@@ -23,6 +24,8 @@ import 'config/config.dart';
2324/// Basic cache manager implementation, which should be used as a single
2425/// instance.
2526class CacheManager implements BaseCacheManager {
27+ static CacheManagerLogLevel logLevel = CacheManagerLogLevel .none;
28+
2629 /// Creates a new instance of a cache manager. This can be used to retrieve
2730 /// files from the cache or download them online. The http headers are used
2831 /// for the maximum age of the files. The BaseCacheManager should only be
@@ -130,8 +133,9 @@ class CacheManager implements BaseCacheManager {
130133 withProgress = false ;
131134 }
132135 } catch (e) {
133- print (
134- 'CacheManager: Failed to load cached file for $url with error:\n $e ' );
136+ cacheLogger.log (
137+ 'CacheManager: Failed to load cached file for $url with error:\n $e ' ,
138+ CacheManagerLogLevel .debug);
135139 }
136140 if (cacheFile == null || cacheFile.validTill.isBefore (DateTime .now ())) {
137141 try {
@@ -145,11 +149,9 @@ class CacheManager implements BaseCacheManager {
145149 }
146150 }
147151 } catch (e) {
148- assert (() {
149- print (
150- 'CacheManager: Failed to download file from $url with error:\n $e ' );
151- return true ;
152- }());
152+ cacheLogger.log (
153+ 'CacheManager: Failed to download file from $url with error:\n $e ' ,
154+ CacheManagerLogLevel .debug);
153155 if (cacheFile == null && streamController.hasListener) {
154156 streamController.addError (e);
155157 }
0 commit comments