Skip to content

Commit

Permalink
fix: Replace console with our logger that also handles log levels
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Mar 23, 2024
1 parent 0f95dce commit 7c06c28
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/components/Folder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { getCurrentUser } from '@nextcloud/auth'
import FolderTagPreview from './FolderTagPreview.vue'
import getAlbumContent from '../services/AlbumContent.js'
import AbortControllerMixin from '../mixins/AbortControllerMixin.js'
import logger from '../services/logger'

export default {
name: 'Folder',
Expand Down Expand Up @@ -122,7 +123,9 @@ export default {
this.$store.dispatch('updateFiles', { folder, files, folders })
} catch (error) {
if (error.response && error.response.status) {
console.error('Failed to get folder content', filename, error.response)
logger.error('Failed to get folder content', { error, filename })
} else {
logger.debug(error)
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/mixins/GridConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

import getGridConfig from '../services/GridConfig.js'
import logger from '../services/logger.js'

/**
* Get the current used grid config
Expand All @@ -36,7 +37,7 @@ export default {
getGridConfig.$on('changed', val => {
this.gridConfig = val
})
console.debug(`[${appName}]`, 'Grid config', Object.assign({}, getGridConfig.gridConfig))
logger.debug('Grid config', { gridConfig: getGridConfig.gridConfig })
this.gridConfig = getGridConfig.gridConfig
},

Expand Down
2 changes: 0 additions & 2 deletions src/services/Albums.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ export async function fetchAlbumContent(path, options, client = davClient) {
}

logger.error('Error fetching album files', { error })
console.error(error)

throw error
}
}
2 changes: 0 additions & 2 deletions src/services/collectionFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ export async function fetchCollectionFiles(path, options, extraProps = [], clien
}

logger.error('Error fetching collection files', { error })
console.error(error)

throw error
}
}
1 change: 0 additions & 1 deletion src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ const actions = {
} catch (error) {
logger.error(t('photos', 'Failed to delete {fileId}.', { fileId }), { error })
showError(t('photos', 'Failed to delete {fileName}.', { fileName: file.basename }))
console.error(error)
context.dispatch('appendFiles', [file])
} finally {
semaphore.release(symbol)
Expand Down
7 changes: 5 additions & 2 deletions src/store/systemtags.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Vue from 'vue'
import { sortCompare } from '../utils/fileUtils.js'
import getTaggedImages from '../services/TaggedImages.js'
import getSystemTags from '../services/SystemTags.js'
import logger from '../services/logger.js'

const state = {
tags: {},
Expand Down Expand Up @@ -81,7 +82,7 @@ const mutations = {
const list = files.sort((a, b) => sortCompare(a, b, 'filesAssigned'))

// overwrite list
console.info(id, list)
logger.debug(`Overwrite list, id: ${id}`, { list })
Vue.set(state.tags[id], 'files', list.map(file => file.fileid))
},
}
Expand Down Expand Up @@ -136,7 +137,9 @@ const actions = {
await context.dispatch('appendFiles', files)
} catch (error) {
if (error.response && error.response.status) {
console.error('Failed to get tag content', id, error.response)
logger.error(`Failed to get tag content, id: ${id}`, { error })
} else {
logger.debug(error)
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/views/Folders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import getAlbumContent from '../services/AlbumContent.js'
import AbortControllerMixin from '../mixins/AbortControllerMixin.js'
import GridConfigMixin from '../mixins/GridConfig.js'
import { fetchFile } from '../services/fileFetcher'
import logger from '../services/logger'

export default {
name: 'Folders',
Expand Down Expand Up @@ -268,7 +269,7 @@ export default {
}
}
// cancelled request, moving on...
console.error('Error fetching album data', error)
logger.error('Error fetching album data', { error })
} finally {
// done loading even with errors
this.loading = false
Expand Down
2 changes: 1 addition & 1 deletion src/views/TagContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default {
await this.$store.dispatch('fetchTagFiles', { id: this.tagId, signal: this.abortController.signal })
}
} catch (error) {
console.error(error)
logger.error(error)
this.error = true
} finally {
// done loading
Expand Down
3 changes: 2 additions & 1 deletion src/views/Tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { NcEmptyContent, NcLoadingIcon } from '@nextcloud/vue'

import TagCover from '../components/TagCover.vue'
import AbortControllerMixin from '../mixins/AbortControllerMixin.js'
import logger from '../services/logger'

export default {
name: 'Tags',
Expand Down Expand Up @@ -115,7 +116,7 @@ export default {
})
}
} catch (error) {
console.error(error)
logger.error(error)
this.error = true
} finally {
// done loading
Expand Down

0 comments on commit 7c06c28

Please sign in to comment.