Skip to content

Commit

Permalink
feat: use wrapper consola
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Dec 31, 2023
1 parent 3e96765 commit d4f5792
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"@vueuse/nuxt": "^10.7.0",
"consola": "^3.2.3",
"yaml": "^2.3.4"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions server/plugins/0.update-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export default defineNitroPlugin(async () => {
const difference = parseVersion(latestPackage.version) - parseVersion(currentPackage.version)

if (difference > 0) {
return console.log(`⚠️ update available: ${latestPackage.version}`)
return logger.warn(`update available: ${latestPackage.version}`)
}

console.log('✅ mafl is up-to-date')
} catch (_) {
console.log('❌ failed to check for an update')
logger.success('mafl is up-to-date')
} catch (e) {
logger.error('failed to check for an update', e)
}
})
8 changes: 8 additions & 0 deletions server/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { consola, createConsola } from 'consola'
import type { ConsolaOptions } from 'consola'

export const logger = consola

export function useLogger(tag?: string, options: Partial<ConsolaOptions> = {}) {
return tag ? createConsola({ ...options, fancy: true }).withTag(tag) : logger
}

0 comments on commit d4f5792

Please sign in to comment.