Permalink
Browse files

[DDW-517] Remove context/time logging in production logs

  • Loading branch information...
nikolaglumac committed Feb 9, 2019
1 parent 867598c commit 9c163fd9cd480bd05014f56d73a229088738f73c
Showing with 8 additions and 5 deletions.
  1. +7 −4 source/common/utils/logging.js
  2. +1 −1 source/main/utils/setupLogging.js
@@ -13,8 +13,9 @@ const DEFAULT_MESSAGE_BODY = {
app: ['daedalus'],
};

const isProd = process.env.NODE_ENV === 'production';

const stringifyMessageBody = (messageBody: MessageBody): string => {
const isProd = process.env.NODE_ENV === 'production';
const spacing = isProd ? 0 : 2;
return JSON.stringify(messageBody, null, spacing);
};
@@ -43,7 +44,7 @@ export const formatContext = (context: FormatMessageContextParams): string => {

export const formatMessageTime = (date: Date): string => {
const [year, time] = date.toISOString().split('T');
return `[${year} ${time.slice(0, -1)} UTC]`;
return `[${year}T${time.slice(0, -1)}Z]`;
};

export const constructMessageBody = (bodyData: ConstructMessageBodyParams): MessageBody => {
@@ -77,8 +78,10 @@ export const formatMessage = (loggerMessage: ElectronLoggerMessage): string => {
thread: '',
};

const messageTime: string = formatMessageTime(loggerMessage.date);
const messageBody: MessageBody = constructMessageBody(messageBodyParams);

return `${context} ${messageTime}\n${stringifyMessageBody(messageBody)}`;
if (isProd) return stringifyMessageBody(messageBody);

const messageTime: string = formatMessageTime(loggerMessage.date);
return `${messageTime} ${context} ${stringifyMessageBody(messageBody)}`;
};
@@ -43,7 +43,7 @@ export const setupLogging = () => {
if (typeof data === 'string') {
messageBody = { ...messageBody, data: { response: data } };
}
return `${context} [${year} ${time.slice(0, -1)} UTC]\n${stringifyData(messageBody)}`;
return `[${year}T${time.slice(0, -1)}Z] ${context} ${stringifyData(messageBody)}`;
};

// Removes existing compressed logs

0 comments on commit 9c163fd

Please sign in to comment.