Skip to content

Commit

Permalink
Merge pull request #3107 from glific/enhancement/adding-logs
Browse files Browse the repository at this point in the history
Added more details to logs
  • Loading branch information
kurund authored Oct 5, 2024
2 parents 1cb80f7 + 69a8f02 commit 6995de4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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 @@ const gqlClient = (navigate: any) => {
// @ts-ignore
switch (networkError.statusCode) {
case 401:
setLogs(`Error 401: logging user out`, 'error');
setLogs(`Error 401: logging user out, ${JSON.stringify(networkError)}`, 'error');
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');

let logger: any;

if (LOGFLARE_API && LOGFLARE_SOURCE) {
Expand Down Expand Up @@ -33,11 +37,13 @@ const setLogs = (message: any, type: string) => {
stream
);

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

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

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

0 comments on commit 6995de4

Please sign in to comment.