|
1 | 1 | import { toast } from "sonner"; |
| 2 | +import { logger } from "./logger"; |
2 | 3 | import { |
3 | 4 | createMetadataExtractor, |
4 | 5 | createFloMetadataExtractor, |
@@ -32,7 +33,11 @@ async function extractAudioMetadata( |
32 | 33 | try { |
33 | 34 | albumArt = await compressAlbumArt(albumArt); |
34 | 35 | } catch (e) { |
35 | | - console.warn("Failed to compress album art:", e); |
| 36 | + if (e instanceof Error) { |
| 37 | + logger.warn("Failed to compress album art:", { error: e.message }); |
| 38 | + } else { |
| 39 | + logger.warn("Failed to compress album art"); |
| 40 | + } |
36 | 41 | } |
37 | 42 | } |
38 | 43 |
|
@@ -104,7 +109,7 @@ export async function importAudioFiles( |
104 | 109 | { type: "audio/wav" }, |
105 | 110 | ); |
106 | 111 | processedMimeType = "audio/wav"; |
107 | | - console.log(`Pre-decoded flo to WAV for Safari: ${file.name}`); |
| 112 | + logger.info(`Pre-decoded flo to WAV for Safari: ${file.name}`); |
108 | 113 | } else { |
109 | 114 | // Non-Safari: Pre-decode to PCM for Web Audio API |
110 | 115 | const { decodeFloToAudioBuffer } = |
@@ -148,13 +153,14 @@ export async function importAudioFiles( |
148 | 153 | // Close the temporary AudioContext |
149 | 154 | await audioContext.close(); |
150 | 155 |
|
151 | | - console.log(`Pre-decoded flo to PCM: ${file.name}`); |
| 156 | + logger.info(`Pre-decoded flo to PCM: ${file.name}`); |
152 | 157 | } |
153 | 158 | } catch (error) { |
154 | | - console.warn( |
155 | | - "Failed to pre-decode flo file, storing original:", |
156 | | - error, |
157 | | - ); |
| 159 | + if (error instanceof Error) { |
| 160 | + logger.warn("Failed to pre-decode flo file, storing original:", { error: error.message }); |
| 161 | + } else { |
| 162 | + logger.warn("Failed to pre-decode flo file, storing original"); |
| 163 | + } |
158 | 164 | // Keep original file if pre-decoding fails |
159 | 165 | processedMimeType = "audio/x-flo"; |
160 | 166 | } |
@@ -192,7 +198,11 @@ export async function importAudioFiles( |
192 | 198 |
|
193 | 199 | successCount++; |
194 | 200 | } catch (error) { |
195 | | - console.error("Failed to process song:", error); |
| 201 | + if (error instanceof Error) { |
| 202 | + logger.error("Failed to process song:", { error: error.message }); |
| 203 | + } else { |
| 204 | + logger.error("Failed to process song"); |
| 205 | + } |
196 | 206 | errorCount++; |
197 | 207 | } |
198 | 208 | } |
|
0 commit comments