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

Added more details to logs #3107

Merged
merged 3 commits into from
Oct 5, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/config/apolloclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
// @ts-ignore
switch (networkError.statusCode) {
case 401:
setLogs(`Error 401: logging user out`, 'error');
setLogs(`Error 401: logging user out, ${JSON.stringify(networkError)}`, 'error');

Check warning on line 108 in src/config/apolloclient.ts

View check run for this annotation

Codecov / codecov/patch

src/config/apolloclient.ts#L108

Added line #L108 was not covered by tests
navigate('/logout/session');
break;
default:
Expand Down
10 changes: 8 additions & 2 deletions src/config/logs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import pino from 'pino';
import { createPinoBrowserSend, createWriteStream } from 'pino-logflare';
import { LOGFLARE_API, LOGFLARE_SOURCE } from '.';
import { getUserSession } from 'services/AuthService';

const setLogs = (message: any, type: string) => {
const orgId = getUserSession('organizationId');
const userId = getUserSession('id');

Check warning on line 8 in src/config/logs.ts

View check run for this annotation

Codecov / codecov/patch

src/config/logs.ts#L7-L8

Added lines #L7 - L8 were not covered by tests

let logger: any;

if (LOGFLARE_API && LOGFLARE_SOURCE) {
Expand Down Expand Up @@ -33,11 +37,13 @@
stream
);

let logMessage = message;
let logMessage;
if (typeof message === 'object') {
logMessage = JSON.stringify(message);
message = JSON.stringify(message);

Check warning on line 42 in src/config/logs.ts

View check run for this annotation

Codecov / codecov/patch

src/config/logs.ts#L42

Added line #L42 was not covered by tests
}

logMessage = `org_id: ${orgId} user_id: ${userId} [${type}] ${message}`;

Check warning on line 45 in src/config/logs.ts

View check run for this annotation

Codecov / codecov/patch

src/config/logs.ts#L45

Added line #L45 was not covered by tests

// log some events
switch (type) {
case 'info':
Expand Down
Loading