Skip to content
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

logging: Make logging.info log to Sentry #5720

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/api/apiFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export const apiCall = async (
const { httpStatus, data } = error instanceof RequestError ? error : {};

const response = data !== undefined ? data : '(none, or not valid JSON)';
logging.info({ route, params, httpStatus, response });
Sentry.addBreadcrumb({
category: 'api',
level: 'info',
Expand Down
7 changes: 0 additions & 7 deletions src/message/__tests__/fetchActions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,19 +392,12 @@ describe('fetchActions', () => {

// $FlowFixMe[prop-missing]: See mock in jest/globalFetch.js.
fetch.mockResponseFailure(fetchError);
// $FlowFixMe[prop-missing]: Jest mock
logging.info.mockReturnValue();

await expect(
store.dispatch(
fetchMessages({ narrow: HOME_NARROW, anchor: 0, numBefore: 1, numAfter: 1 }),
),
).rejects.toThrow(fetchError);

// $FlowFixMe[prop-missing]: Jest mock
expect(logging.info.mock.calls).toHaveLength(1);
// $FlowFixMe[prop-missing]: Jest mock
logging.info.mockReset();
});
});

Expand Down
22 changes: 13 additions & 9 deletions src/utils/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,20 @@ export const warn: (event: string | Error, extras?: Extras) => void = makeLogFun
/**
* Log an event at "info" severity.
*
* The event will be logged to the console as appropriate.
*
* This will *not* log any information to Sentry. Consider also calling
* `Sentry.addBreadcrumb`.
* The event will be logged to Sentry and/or the console as appropriate.
*
* See also:
* * `logging.warn` and `logging.error` for logging at higher severity
* * `Sentry.addBreadcrumb`, to add background data to an eventual Sentry
* report, but without causing a Sentry report.
*
* @param event A string describing the nature of the event to be logged, or an
* exception whose `.message` is such a string. Related events should have
* identical such strings, when feasible.
* @param extras Diagnostic data which may differ between separate occurrences
* of the event.
*/
export const info = (event: string | Error | { ... }) => {
if (config.enableErrorConsoleLogging) {
console.log(event);
}
};
export const info: (event: string | Error, extras?: Extras) => void = makeLogFunction({
consoleMethod: console.info,
severity: Severity.Info,
});