-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjsonLogScript
34 lines (29 loc) · 1.11 KB
/
jsonLogScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Function called to extract date, level, app name and message
//
// @param preJSONString: string - optional non-JSON string proceeding JSON object
// @param jsonObject: {} - JSON log data
// @returns {date: Date, level: string, category: string, appName: string, message: string, rawLine: string, additionalJSON: {} }
//
// category is the availability zone
// appName is the pod name
//
const extractDateLevelCategoryAppNameMessage = function (preJSONString, jsonObject) {
let level = 'info';
let date = new Date();
let category = '';
let appName = 'App_name_is_not_set';
let message = 'Message is not set - edit or replace client/public/plugins/parsejson/plugin.js';
// return raw JSON (optional)
let rawLine;
// Copy any JSON fields not defined in jsonObject
let additionalJSON = {};
// Set the level
// level = jsonObject.m_level;
// Set the date
// date = jsonObject.my_date;
// Set the app name
//appName = jsonObject.my_app;
// Set message
//message = jsonObject.my_message;
return { date, level, category, appName, message, rawLine, additionalJSON };
}