File tree 2 files changed +14
-3
lines changed
Sources/Pulse/LoggerStore
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ extension LoggerStore {
74
74
/// If `true`, the images added to the store as saved as small thumbnails.
75
75
public var isStoringOnlyImageThumbnails = true
76
76
77
+ /// Defines how to generate the thumbnails for the images from network responses.
78
+ public var imageThumbnailOptions = ThumbnailOptions ( )
79
+
77
80
/// Limit the maximum response size stored by the logger. The default
78
81
/// value is `8 MB`. The same limit applies to requests.
79
82
public var responseBodySizeLimit : Int = 8 * 1048576
@@ -104,4 +107,11 @@ extension LoggerStore {
104
107
self . sizeLimit = sizeLimit
105
108
}
106
109
}
110
+
111
+ /// The configuration options for storing thumbnails for network responses
112
+ /// containing media.
113
+ public struct ThumbnailOptions {
114
+ public var maximumPixelSize : CGFloat = 512
115
+ public var compressionQuality : CGFloat = 0.5
116
+ }
107
117
}
Original file line number Diff line number Diff line change @@ -491,14 +491,15 @@ extension LoggerStore {
491
491
}
492
492
493
493
private func preprocessData( _ data: Data , contentType: NetworkLogger . ContentType ? ) -> Data {
494
- guard data. count > 20_000 else { // 20 KB is ok
494
+ guard data. count > 15_000 else { // 15 KB is ok
495
495
return data
496
496
}
497
497
guard configuration. isStoringOnlyImageThumbnails && ( contentType? . isImage ?? false ) else {
498
498
return data
499
499
}
500
- guard let thumbnail = Graphics . makeThumbnail ( from: data, targetSize: 512 ) ,
501
- let data = Graphics . encode ( thumbnail, compressionQuality: 0.7 ) else {
500
+ let options = configuration. imageThumbnailOptions
501
+ guard let thumbnail = Graphics . makeThumbnail ( from: data, targetSize: options. maximumPixelSize) ,
502
+ let data = Graphics . encode ( thumbnail, compressionQuality: options. compressionQuality) else {
502
503
return data
503
504
}
504
505
return data
You can’t perform that action at this time.
0 commit comments