Sentry Logger
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
import Logger from './logger'; | |
// console.log('ye message') | |
Logger.log('my message') | |
// console.error('error message') | |
Logger.log('error message', 'error'); | |
Logger.error('error message') | |
try { | |
NotReal.call() | |
} catch(e) { | |
Logger.captureException(e) | |
} |
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
import * as Sentry from 'sentry-expo'; | |
const log = (message, level) => { | |
console.log(message); | |
Sentry.addBreadcrumb({ | |
message, | |
level, | |
}) | |
}; | |
const captureMessage = (message, level) => { | |
try { | |
console.reportErrorsAsExceptions = false; | |
Sentry.captureMessage(message, level) | |
} catch { | |
console.log('Failed to send message to Sentry') | |
} finally { | |
console.reportErrorsAsExceptions = true | |
} | |
}; | |
const captureException = (exception) => { | |
try { | |
console.reportErrorsAsExceptions = false; | |
Sentry.captureException(exception) | |
} catch { | |
console.log('Failed to send exception to Sentry'); | |
console.reportErrorsAsExceptions = true | |
} | |
}; | |
const Logger = { | |
debug: msg => log(msg, 'debug'), | |
info: msg => log(msg, 'info'), | |
error: msg => log(msg, 'error'), | |
captureMessage, | |
captureException, | |
}; | |
export default Logger; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment