-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a transport to the pino logger library to forward your messages to Logflare. This can be verified locally by adding a `.env` file with the following values: ``` REACT_APP_LOGFLARE_KEY=<LOG_FLARE_API_KEY> REACT_APP_LOGFLARE_SOURCE=<LOGFLARE_SOURCE_ID> ``` This is a trial with Logflare, we can easily switch to another provider at a later date.
- Loading branch information
1 parent
441d860
commit 0ff8fce
Showing
4 changed files
with
177 additions
and
16 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 |
---|---|---|
@@ -1,6 +1,28 @@ | ||
import Logger from 'pino' | ||
import { createPinoBrowserSend, createWriteStream } from 'pino-logflare' | ||
import { getConfigirationOption } from 'src/config/config'; | ||
|
||
const logLevel = getConfigirationOption('REACT_APP_LOG_LEVEL', 'warn'); | ||
|
||
export const logger = Logger({ browser: { asObject: false }, level: logLevel }) | ||
let loggerInstance; | ||
|
||
if (getConfigirationOption('REACT_APP_LOGFLARE_KEY', '')) { | ||
const logflareConfiguration = { | ||
apiKey: getConfigirationOption('REACT_APP_LOGFLARE_KEY', ''), | ||
sourceToken: getConfigirationOption('REACT_APP_LOGFLARE_SOURCE', '') | ||
}; | ||
|
||
loggerInstance = Logger({ | ||
browser: { | ||
transmit: { | ||
send: createPinoBrowserSend(logflareConfiguration) | ||
} | ||
}, | ||
level: logLevel | ||
}, createWriteStream(logflareConfiguration)) | ||
} else { | ||
loggerInstance = Logger({ browser: { asObject: false }, level: logLevel }); | ||
} | ||
|
||
|
||
export const logger = loggerInstance; |
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