This is a simple wrapper for sending logs
$ yarn add @colorfy-software/logify
// core/logging-core.ts
import Logify from '@colorfy-software/logify'
interface CustomErrorType {
message: string
code: number
}
const logger = new Logify<CustomErrorType>({
endpoint: 'http://some-endpoint.com',
// Can be an object or a function, get's added to each log
defaultParams?: {
userId: getUserId()
source: 'app'
},
// Error here has CustomErrorType | DefaultErrorType(from lib), can parse error to be something useful
parseError?: (error) => {
// do stuff with error
return parsedErrorMessage
},
// Condition if logs should be sent to server. Can be a function. Defaults to true
shouldSendLogsIf?: !__DEV__,
// Condition if logs should be shown in console. Can be a function. Defaults to true
shouldLogToConsoleIf?: true,
// Possibility to edit colors that are printed to console
printColors?: {
debug?: string,
info?: string,
warn?: string,
error?: string,
fatal?: string,
}
})
export default logger
// any-file.ts
import core from '../core'
core.logger.error('userRegistrationError', gigyaError)