-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[v6] utils Logging #2526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
[v6] utils Logging #2526
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8b1f7b2
logger barebones
xzilja 8acfbc8
add colors and args
xzilja 86d42bf
allow object as params
xzilja 8eee7c0
Merge branch 'master' into @ilja/logging
xzilja f7dcedc
Merge branch 'master' into @ilja/logging
iljadaderko 608a6e4
add logger types, handle default null param value
xzilja 2fccc5b
add logger documentation
xzilja dfc489e
Add logger tests, documentation and types
xzilja 6f8213c
disable logging by default
xzilja 9911404
Merge branch 'master' into @ilja/logging
iljadaderko 04e9f66
formating
xzilja 8ee4634
Merge branch '@ilja/logging' of https://github.com/invertase/react-na…
xzilja 82573c7
address pr comments
xzilja 2082e00
Merge branch 'master' into @ilja/logging
iljadaderko 4139694
Merge branch 'master' into @ilja/logging
Salakar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,47 @@ | ||
/* eslint-disable no-console */ | ||
/** | ||
* List of ansi colors | ||
* @url https://github.com/shiena/ansicolor/blob/master/README.md | ||
*/ | ||
|
||
import { isArray, isNull, isObject, isString } from '@react-native-firebase/app/lib/common'; | ||
|
||
const config = { | ||
enableMethodLogging: false, | ||
enableEventLogging: false, | ||
}; | ||
|
||
/** | ||
* Resets terminal to default color | ||
*/ | ||
function resetTerminalColor() { | ||
console.log('\x1b[0m'); | ||
} | ||
|
||
/** | ||
* Info level log | ||
* @param {String} text | ||
* @param {Array} params | ||
*/ | ||
function info(text, params = null) { | ||
if (!isString(text)) { | ||
throw new Error(`Invalid text passed to logger. Expected string, but got ${typeof text}`); | ||
} | ||
console.log('\x1b[35m', text); | ||
|
||
if (!isArray(params) && !isObject(params) && !isNull(params)) { | ||
throw new Error( | ||
`Invalid params passed to logger. Expected array or object, but got ${typeof params}`, | ||
); | ||
} | ||
if (params) { | ||
console.log('\x1b[94m', JSON.stringify(params, null, 2)); | ||
} | ||
|
||
resetTerminalColor(); | ||
} | ||
|
||
export default { | ||
config, | ||
info, | ||
}; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will get added to the docs so worth having a quick description above it.