Skip to content

Commit

Permalink
Adopts debugPrint() everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyLB committed Oct 1, 2024
1 parent bf42ed9 commit 0d498b6
Show file tree
Hide file tree
Showing 84 changed files with 403 additions and 402 deletions.
2 changes: 1 addition & 1 deletion piwigo/Album/AlbumCollection/AlbumRenaming.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class AlbumRenaming: NSObject
do {
try mainContext.save()
} catch let error as NSError {
print("Could not save context, \(error.userInfo)")
debugPrint("Could not save context, \(error.userInfo)")
}

// Hide HUD
Expand Down
6 changes: 3 additions & 3 deletions piwigo/Album/AlbumNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class AlbumNavigationController: UINavigationController
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
print("============================================")
print("••> viewDidLoad in AlbumNavigationController")
debugPrint("============================================")
debugPrint("••> viewDidLoad in AlbumNavigationController")

// Navigation bar
navigationBar.accessibilityIdentifier = "AlbumImagesNav"
Expand Down Expand Up @@ -84,7 +84,7 @@ class AlbumNavigationController: UINavigationController

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("••> viewWillAppear in AlbumNavigationController")
debugPrint("••> viewWillAppear in AlbumNavigationController")

// Set colors, fonts, etc.
applyColorPalette()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extension SelectCategoryViewController {
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not fetch \(error), \(error.userInfo)")
debugPrint("Could not fetch \(error), \(error.userInfo)")
}

// Close HUD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension SelectCategoryViewController {
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save copied images \(error), \(error.userInfo)")
debugPrint("Could not save copied images \(error), \(error.userInfo)")
}
// Hide HUD and dismiss album selector
self.hideHUD(afterDelay: pwgDelayHUD) {
Expand Down Expand Up @@ -108,7 +108,7 @@ extension SelectCategoryViewController {
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save moved images \(error), \(error.userInfo)")
debugPrint("Could not save moved images \(error), \(error.userInfo)")
}

// Hide HUD and dismiss album selector
Expand Down
8 changes: 4 additions & 4 deletions piwigo/Album/AlbumSelector/SelectCategoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class SelectCategoryViewController: UIViewController, UITableViewDataSource, UIT
try recentAlbums.performFetch()
try albums.performFetch()
} catch {
print("Error: \(error)")
debugPrint("Error: \(error)")
}

// Button for returning to albums/images collections
Expand Down Expand Up @@ -582,7 +582,7 @@ class SelectCategoryViewController: UIViewController, UITableViewDataSource, UIT
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

guard let cell = tableView.dequeueReusableCell(withIdentifier: "CategoryTableViewCell", for: indexPath) as? CategoryTableViewCell else {
print("Error: tableView.dequeueReusableCell does not return a CategoryTableViewCell!")
debugPrint("Error: tableView.dequeueReusableCell does not return a CategoryTableViewCell!")
return CategoryTableViewCell()
}

Expand Down Expand Up @@ -736,7 +736,7 @@ class SelectCategoryViewController: UIViewController, UITableViewDataSource, UIT
switch wantedAction {
case .setDefaultAlbum:
// The current default category is not selectable
print("••> albums: \(albumData.pwgID) and \(inputAlbum.pwgID)")
debugPrint("••> albums: \(albumData.pwgID) and \(inputAlbum.pwgID)")
if albumData.pwgID == inputAlbum.pwgID {
return false
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ class SelectCategoryViewController: UIViewController, UITableViewDataSource, UIT
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not fetch \(error), \(error.userInfo)")
debugPrint("Could not fetch \(error), \(error.userInfo)")
}
// Dismiss the view
self.dismiss(animated: true, completion: {})
Expand Down
14 changes: 7 additions & 7 deletions piwigo/Album/AlbumViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ class AlbumViewController: UIViewController
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
print("--------------------------------------------------")
print("••> viewDidLoad in AlbumViewController: Album #\(categoryId)")
debugPrint("--------------------------------------------------")
debugPrint("••> viewDidLoad in AlbumViewController: Album #\(categoryId)")

// Initialise data source
do {
Expand All @@ -239,7 +239,7 @@ class AlbumViewController: UIViewController
}
try images.performFetch()
} catch {
print("Error: \(error)")
debugPrint("Error: \(error)")
}

// Place search bar in navigation bar of root album
Expand Down Expand Up @@ -381,7 +381,7 @@ class AlbumViewController: UIViewController

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("••> viewWillAppear in AlbumViewController: Album #\(categoryId)")
debugPrint("••> viewWillAppear in AlbumViewController: Album #\(categoryId)")

// For testing…
// timeCounter = CFAbsoluteTimeGetCurrent()
Expand Down Expand Up @@ -415,14 +415,14 @@ class AlbumViewController: UIViewController

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
print("••> viewDidAppear in AlbumViewController: Album #\(categoryId)")
debugPrint("••> viewDidAppear in AlbumViewController: Album #\(categoryId)")

// Speed and memory measurements with iPad Pro 11" in debug mode
/// Old method —> 0 photo: 527 ms, 24 photos: 583 ms, 3020 photos: 15 226 ms (memory crash after repeating tests)
/// hasFavorites cached —> a very little quicker but less memory impacting (-195 MB transcient allocations for 3020 photos)
/// placeHolder & size cached —> 0 photo: 526 ms, 24 photos: 585 ms, 3020 photos: 14 586 ms i.e. -6% (memory crash after repeating tests)
// let duration = (CFAbsoluteTimeGetCurrent() - timeCounter)*1000
// print("••> completed in \(duration.rounded()) ms")
// debugPrint("••> completed in \(duration.rounded()) ms")

// The user may have cleared the cached data
// Display an empty root album in that case
Expand Down Expand Up @@ -635,7 +635,7 @@ class AlbumViewController: UIViewController
.value(forHTTPHeaderField: NetworkVars.HTTPCatID) == catIDstr })
// Cancel remaining tasks related with this completed upload request
tasksToCancel.forEach({
print("\(DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .medium)) > Cancel task \($0.taskIdentifier) related with album \(self.categoryId)")
debugPrint("\(DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .medium)) > Cancel task \($0.taskIdentifier) related with album \(self.categoryId)")
$0.cancel()
})
}
Expand Down
12 changes: 6 additions & 6 deletions piwigo/Album/Extensions/AlbumViewController+Delete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extension AlbumViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save moved images \(error), \(error.userInfo)")
debugPrint("Could not save moved images \(error), \(error.userInfo)")
}
// Hide HUD and deselect images
navigationController?.hideHUD() { [self] in
Expand Down Expand Up @@ -227,7 +227,7 @@ extension AlbumViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save moved images \(error), \(error.userInfo)")
debugPrint("Could not save moved images \(error), \(error.userInfo)")
}
// Hide HUD and update buttons
updateBarsInSelectMode()
Expand All @@ -246,7 +246,7 @@ extension AlbumViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save moved images \(error), \(error.userInfo)")
debugPrint("Could not save moved images \(error), \(error.userInfo)")
}
// Hide HUD and update buttons
updateBarsInSelectMode()
Expand All @@ -262,7 +262,7 @@ extension AlbumViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save deleted images \(error), \(error.userInfo)")
debugPrint("Could not save deleted images \(error), \(error.userInfo)")
}
// Hide HUD and deselect images
navigationController?.hideHUD(afterDelay: pwgDelayHUD) { [self] in
Expand Down Expand Up @@ -297,7 +297,7 @@ extension AlbumViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save albums after image deletion \(error), \(error.userInfo)")
debugPrint("Could not save albums after image deletion \(error), \(error.userInfo)")
}

// Delete upload requests of images deleted from the Piwigo server
Expand Down Expand Up @@ -338,7 +338,7 @@ extension AlbumViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save moved images \(error), \(error.userInfo)")
debugPrint("Could not save moved images \(error), \(error.userInfo)")
}
// Hide HUD and update buttons
navigationController?.hideHUD() { [self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension AlbumViewController: NSFetchedResultsControllerDelegate
selectedVideosIDs.remove(image.pwgID)
// Delete image
updateOperations.append( BlockOperation { [weak self] in
debugPrint("••> Delete image of album #\(self?.categoryId ?? Int32.min) at \(indexPath)")
// debugPrint("••> Delete image of album #\(self?.categoryId ?? Int32.min) at \(indexPath)")
self?.collectionView?.deleteItems(at: [indexPath])
})
case .move:
Expand Down
2 changes: 1 addition & 1 deletion piwigo/Album/Extensions/AlbumViewController+Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ extension AlbumViewController: ImageHeaderDelegate
selectedSections[section] = .select
}
// let diff = (CFAbsoluteTimeGetCurrent() - start)*1000
// print("=> Select/Deselect \(localImagesCollection.numberOfItems(inSection: section)) images of section \(section) took \(diff) ms")
// debugPrint("=> Select/Deselect \(localImagesCollection.numberOfItems(inSection: section)) images of section \(section) took \(diff) ms")

// Update navigation bar and toolbar
updateBarsInSelectMode()
Expand Down
4 changes: 2 additions & 2 deletions piwigo/Album/Extensions/AlbumViewController+Prefetching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import piwigoKit
extension AlbumViewController: UICollectionViewDataSourcePrefetching
{
func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
// print("••> prefetchingItemsAt \(indexPaths.debugDescription)")
// debugPrint("••> prefetchingItemsAt \(indexPaths.debugDescription)")
let scale = self.traitCollection.displayScale
for indexPath in indexPaths {
switch indexPath.section {
Expand Down Expand Up @@ -51,7 +51,7 @@ extension AlbumViewController: UICollectionViewDataSourcePrefetching
}

func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) {
// print("••> cancelPrefetchingForItemsAt \(indexPaths.debugDescription)")
// debugPrint("••> cancelPrefetchingForItemsAt \(indexPaths.debugDescription)")
for indexPath in indexPaths {
switch indexPath.section {
case 0 /* Albums (see XIB file) */:
Expand Down
2 changes: 1 addition & 1 deletion piwigo/Album/Extensions/AlbumViewController+Share.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension AlbumViewController
}
}
// let duration = (CFAbsoluteTimeGetCurrent() - timeCounter)*1000
// print("••> completed in \(duration.rounded()) ms")
// debugPrint("••> completed in \(duration.rounded()) ms")

// Close HUD if needed
DispatchQueue.main.async {
Expand Down
2 changes: 1 addition & 1 deletion piwigo/Album/TagSelector/TagSelectorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class TagSelectorViewController: UITableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
guard let cell = tableView.dequeueReusableCell(withIdentifier: "TagSelectorCell", for: indexPath) as? TagSelectorCell else {
print("Error: tableView.dequeueReusableCell does not return a TagSelectorCell!")
debugPrint("Error: tableView.dequeueReusableCell does not return a TagSelectorCell!")
return TagSelectorCell()
}
cell.configure(with: tags.object(at: indexPath))
Expand Down
4 changes: 2 additions & 2 deletions piwigo/Image/Extensions/ImageViewController+Delete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ extension ImageViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save copied images \(error), \(error.userInfo)")
debugPrint("Could not save copied images \(error), \(error.userInfo)")
}
}

Expand Down Expand Up @@ -191,7 +191,7 @@ extension ImageViewController
do {
try self.mainContext.save()
} catch let error as NSError {
print("Could not save albums after image deletion \(error), \(error.userInfo)")
debugPrint("Could not save albums after image deletion \(error), \(error.userInfo)")
}

// If this image was uploaded with the iOS app,
Expand Down
10 changes: 5 additions & 5 deletions piwigo/Image/ImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class ImageViewController: UIViewController {
}

deinit {
print("••> ImageViewController is being deinitialized.")
// debugPrint("••> ImageViewController is being deinitialized.")
// Unregister all observers
NotificationCenter.default.removeObserver(self)
}
Expand Down Expand Up @@ -723,7 +723,7 @@ class ImageViewController: UIViewController {
// Buttons are disabled (greyed) when retrieving image data
// They are also disabled during an action
func setEnableStateOfButtons(_ state: Bool) {
print("••> \(state ? "Enable" : "Disable") buttons")
// debugPrint("••> \(state ? "Enable" : "Disable") buttons")
actionBarButton?.isEnabled = state
shareBarButton.isEnabled = state
moveBarButton.isEnabled = state
Expand Down Expand Up @@ -883,7 +883,7 @@ extension ImageViewController: UIPageViewControllerDelegate
}

// Set title and buttons
print("••> Did finish animating page view controller for image at index \(indexPath)")
// debugPrint("••> Did finish animating page view controller for image at index \(indexPath)")
setTitleViewFromImageData()
updateNavBar()
setEnableStateOfButtons(imageData.fileSize != Int64.zero)
Expand All @@ -910,7 +910,7 @@ extension ImageViewController: UIPageViewControllerDataSource
{
// Create view controller for presenting the image at the provided index
func imageDetailViewController(ofImage imageData: Image, atIndexPath indexPath: IndexPath) -> ImageDetailViewController? {
print("••> Create page view controller for image #\(imageData.pwgID) at index \(indexPath)")
// debugPrint("••> Create page view controller for image #\(imageData.pwgID) at index \(indexPath)")
guard let imageDVC = storyboard?.instantiateViewController(withIdentifier: "ImageDetailViewController") as? ImageDetailViewController
else { return nil }

Expand All @@ -922,7 +922,7 @@ extension ImageViewController: UIPageViewControllerDataSource

// Create view controller for presenting the video at the provided index
func videoDetailViewController(ofImage imageData: Image, atIndexPath indexPath: IndexPath) -> VideoDetailViewController? {
debugPrint("••> Create page view controller for video #\(imageData.pwgID) at index \(indexPath)")
// debugPrint("••> Create page view controller for video #\(imageData.pwgID) at index \(indexPath)")
guard let videoDVC = storyboard?.instantiateViewController(withIdentifier: "VideoDetailViewController") as? VideoDetailViewController
else { return nil }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ extension EditImageDatePickerTableViewCell: UIPickerViewDelegate
// var rightPaneWidth = sepDay / 2 + 5 * separatorWidth + 3 * time + 2 * sepTime
// rightPaneWidth += is24hFormat ? 0.0 : separatorWidth + ampm + separatorWidth + rightMargin
// let remainingSpace = pickerView.bounds.size.width - leftPaneWidth - rightPaneWidth
// print("=> left:\(leftPaneWidth), right:\(rightPaneWidth), width:\(pickerView.bounds.size.width) (remaining:\(remainingSpace))")
// debugPrint("=> left:\(leftPaneWidth), right:\(rightPaneWidth), width:\(pickerView.bounds.size.width) (remaining:\(remainingSpace))")
// iPhone SE, iOS 11 => left:136, right:179, width:318 (remaining:3)
// iPhone Xs, iOS 12 => left:131, right:174, width:373 (remaining:68)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension EditImageThumbTableViewCell: UICollectionViewDataSource

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "EditImageThumbCollectionViewCell", for: indexPath) as? EditImageThumbCollectionViewCell else {
print("Error: collectionView.dequeueReusableCell does not return a EditImageThumbCollectionViewCell!")
debugPrint("Error: collectionView.dequeueReusableCell does not return a EditImageThumbCollectionViewCell!")
return EditImageThumbCollectionViewCell()
}
cell.config(withImage: images?[indexPath.row], removeOption: ((images?.count ?? 0) > 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension EditImageParamsViewController: EditImageThumbnailCellDelegate
do {
try mainContext.save()
} catch let error as NSError {
print("Could not fetch \(error), \(error.userInfo)")
debugPrint("Could not fetch \(error), \(error.userInfo)")
}

// Update parent image view
Expand Down
2 changes: 1 addition & 1 deletion piwigo/Image/Parameters/Tags/TagsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class TagsViewController: UITableViewController {

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "TagTableViewCell", for: indexPath) as? TagTableViewCell else {
print("Error: tableView.dequeueReusableCell does not return a TagTableViewCell!")
debugPrint("Error: tableView.dequeueReusableCell does not return a TagTableViewCell!")
return TagTableViewCell()
}
switch indexPath.section {
Expand Down
Loading

0 comments on commit 0d498b6

Please sign in to comment.