-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(suite-desktop): create facade over ILogger to make it compatibl…
…e with Log
- Loading branch information
Showing
7 changed files
with
64 additions
and
48 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
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,32 @@ | ||
import { Log, LogMessage as UtilsLogMessage } from '@trezor/utils'; | ||
|
||
/** take an instance of ILogger and return mimicked instance of Log while keeping more or less the same behavior */ | ||
export const convertILoggerToLog = ( | ||
iLogger: ILogger, | ||
{ serviceName }: { serviceName: string }, | ||
): Log => { | ||
return { | ||
log: (msg: string) => iLogger.info(serviceName, msg), | ||
info: (msg: string) => iLogger.info(serviceName, msg), | ||
debug: (msg: string) => iLogger.debug(serviceName, msg), | ||
warn: (msg: string) => iLogger.warn(serviceName, msg), | ||
error: (msg: string) => iLogger.error(serviceName, msg), | ||
prefix: '', | ||
messages: [], | ||
enabled: true, | ||
css: '', | ||
MAX_ENTRIES: 1000, | ||
setColors: (_colors: any) => {}, | ||
setWriter: (_logWriter: any) => {}, | ||
addMessage: (_msg: UtilsLogMessage) => {}, | ||
logWriter: undefined, | ||
getLog: (): UtilsLogMessage[] => { | ||
return iLogger.getLog().map(log => ({ | ||
message: [log.text], | ||
prefix: '', | ||
level: log.level, | ||
timestamp: log.date.getTime(), | ||
})); | ||
}, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { Log } from '@trezor/utils'; | ||
|
||
import { TrezordNode } from './http'; | ||
|
||
const trezordNode = new TrezordNode({ port: 21325, api: 'usb' }); | ||
const trezordNode = new TrezordNode({ | ||
port: 21325, | ||
api: 'usb', | ||
logger: new Log('@trezor/transport-bridge', true), | ||
}); | ||
|
||
trezordNode.start(); |
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