Skip to content

Commit

Permalink
refactor: useVueLogger now accepts logLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
Uninen committed Nov 14, 2024
1 parent 58b59e9 commit f1a99bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 0.3.0 - 2024-11-14

- refactor: changed `useVueLogger` to accept logLevel argument
- ci: only release after tests pass
- chore: upgrade Renovate config
- chore: bump deps
Expand Down
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,12 @@ const useLogger = (name?: string, debug: boolean = false): Logger => {
})
}

const useVueLogger = (name?: string, debug: boolean = false): Logger => {
let level = LogLevel.INFO
if (debug) {
level = LogLevel.DEBUG
const useVueLogger = (name?: string, level?: LogLevel): Logger => {
if (!level) {
level = import.meta.env.MODE === 'development' ? LogLevel.INFO : LogLevel.ERROR
}
return new Logger({
logLevel: import.meta.env.MODE === 'development' ? level : LogLevel.ERROR,
logLevel: level,
logFn: VueLogFn,
name: name,
})
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ describe('Vue logger', () => {
})

it('works with useLogger', () => {
const mylogger = useVueLogger()
const mylogger = useVueLogger('test', LogLevel.INFO)
mylogger.log('hello vue')
expect(consoleOutput.length).toBe(1)
})

it('sets options correctly', () => {
const mylogger = useVueLogger()
const mylogger = useVueLogger('test', LogLevel.INFO)

mylogger.debug('hello vue')
expect(consoleOutput.length).toBe(0)
Expand Down

0 comments on commit f1a99bc

Please sign in to comment.