-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add js console log to native logger
Signed-off-by: Guilhem Fanton <guilhem.fanton@gmail.com>
- Loading branch information
Showing
11 changed files
with
100 additions
and
34 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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
* https://github.com/facebook/react-native | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
import React from 'react' | ||
|
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import GoBridge from './GoBridge' | ||
|
||
import BridgeLogger from './logger' | ||
const BridgeConsole = { | ||
...console, | ||
...BridgeLogger(GoBridge), | ||
} | ||
|
||
import { GoBridgeInterface, GoBridgeOpts, GoLogLevel } from './types' | ||
|
||
export type { GoBridgeInterface, GoBridgeOpts } | ||
|
||
export { GoLogLevel } | ||
export { GoLogLevel, BridgeConsole } | ||
|
||
export default GoBridge |
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,37 @@ | ||
import { GoLogLevel, GoBridgeInterface } from './types' | ||
|
||
const formatMessage = (...args: any[]): string => | ||
args | ||
.map((e) => JSON.stringify(e)) | ||
.join(' ') | ||
.replace(/\\"/g, '"') | ||
|
||
const BridgeLogger = (bridge: GoBridgeInterface) => ({ | ||
log: (message?: any, ...opts: any[]): void => | ||
bridge.log({ | ||
level: GoLogLevel.debug, | ||
message: formatMessage(message, ...opts), | ||
}), | ||
debug: (message?: any, ...opts: any[]): void => | ||
bridge.log({ | ||
level: GoLogLevel.debug, | ||
message: formatMessage(message, ...opts), | ||
}), | ||
warn: (message?: any, ...opts: any[]): void => | ||
bridge.log({ | ||
level: GoLogLevel.warn, | ||
message: formatMessage(message, ...opts), | ||
}), | ||
error: (message?: any, ...opts: any[]): void => | ||
bridge.log({ | ||
level: GoLogLevel.error, | ||
message: formatMessage(message, ...opts), | ||
}), | ||
info: (message?: any, ...opts: any[]): void => | ||
bridge.log({ | ||
level: GoLogLevel.info, | ||
message: formatMessage(message, ...opts), | ||
}), | ||
}) | ||
|
||
export default BridgeLogger |
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