This repository has been archived by the owner on Jul 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract logger implementations (#1716)
Co-authored-by: crapStone <crapstone01@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1716 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: crapStone <crapstone@noreply.codeberg.org> Co-committed-by: crapStone <crapstone@noreply.codeberg.org>
- Loading branch information
1 parent
a31aea6
commit a02b2ba
Showing
4 changed files
with
45 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { invoke } from '@tauri-apps/api/tauri'; | ||
import { LogLevel } from '../logger'; | ||
import logWeb from './web.logger-impl'; | ||
|
||
export default (level: LogLevel, path: string, ...messages: any[]): void => { | ||
logWeb(level, path, ...messages); | ||
invoke('plugin:cabr2_logger|log', { | ||
level, | ||
path, | ||
messages, | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { LogLevel } from '../logger'; | ||
|
||
export default (level: LogLevel, path: string, ...messages: any[]): void => { | ||
let fn; | ||
switch (level) { | ||
case LogLevel.TRACE: | ||
case LogLevel.DEBUG: | ||
case LogLevel.INFO: | ||
fn = console.log; | ||
break; | ||
|
||
case LogLevel.WARNING: | ||
fn = console.warn; | ||
break; | ||
|
||
case LogLevel.ERROR: | ||
fn = console.error; | ||
break; | ||
} | ||
|
||
fn(`[${level}]`, `[${path}]`, ...messages); | ||
}; |