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

1.3.2 release branch - DO NOT MERGE :P #855

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
54cb35f
GPII-3572: Added the ability to start only metrics via configuration.
stegru Dec 11, 2018
95afd28
GPII-3572: Added the ability to start with/without metrics via config…
stegru Dec 11, 2018
52397d2
GPII-3572: Logging the start of metrics
stegru Dec 12, 2018
61eda5d
NOJIRA: Lower-casing the first character of error objects.
stegru Dec 12, 2018
46b54f3
Merge remote-tracking branch 'upstream/master' into GPII-3572
stegru Dec 12, 2018
32e9440
Merge remote-tracking branch 'upstream/master' into GPII-3572
stegru Dec 12, 2018
4888c7b
GPII-3780: Fixed 'com.microsoft.windows.desktopBackgroundColor' and '…
JavierJF Mar 8, 2019
e008b49
GPII-3780: Improved tests for 'windows.desktopBackground' and 'window…
JavierJF Mar 8, 2019
2030606
GPII-3780: Added new preference sets for 'windows.desktopBackgroundCo…
JavierJF Mar 8, 2019
4f910c6
GPII-3780: Solved linter issues
JavierJF Mar 8, 2019
26bd1a9
GPII-3853: Implemented sub-sessions.
stegru Jun 24, 2019
cdadc33
GPII-3853: Recording inactivity due to entering sleep mode
stegru Jun 25, 2019
1d7ac64
GPII-3853: Added calculation of duration between related events.
stegru Jun 25, 2019
1eb3050
GPII-3853: Recording setting changes, and noting if they're in respon…
stegru Jun 26, 2019
dc3592d
GPII-3853: Improved the logging of session ends.
stegru Jun 26, 2019
7c17730
GPII-3853: Updated metrics documentation
stegru Jun 26, 2019
a5dbaa7
GPII-3853: replaced keyIn field with logon
stegru Jun 26, 2019
1f556d4
GPII-3853: Recording the state of the QSS.
stegru Jul 1, 2019
bf258bc
GPII-3853: Documenting recent changes
stegru Jul 1, 2019
17f352e
GPII-3853: Disabling metrics via siteConfig
stegru Jul 2, 2019
a27f13b
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Jul 2, 2019
27ac598
GPII-3852: Removed unexpected item in the bagging area
stegru Jul 4, 2019
4f1b4a3
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Jul 5, 2019
ea8ffb7
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Jul 8, 2019
e0b926e
GPII-3853: Added metrics for notification and error dialogs
stegru Jul 9, 2019
6524c2e
GPII-3853: Updated documentation
stegru Jul 9, 2019
a30aa8e
GPII-3853: Increased login time
stegru Jul 9, 2019
0cd1320
GPII-3853: Removed logging of metrics from the log file.
stegru Jul 17, 2019
c9ff113
Merge branch 'master' of https://github.com/GPII/universal into GPII-…
JavierJF Jul 26, 2019
13d4b5a
GPII-3780: Simplified transformation due to GPII-3784 being solve
JavierJF Jul 26, 2019
a9d702e
GPII-3780: Improve the tranformation for "ImageConfig" in win32.json5.
cindyli Jul 26, 2019
946756e
Merge pull request #1 from cindyli/GPII-3780
JavierJF Jul 26, 2019
fd9a73f
Merge branch 'master' of https://github.com/GPII/universal into GPII-…
JavierJF Aug 5, 2019
0b705aa
GPII-3780: Removed unnecessary transform due to GPII-3784 being alrea…
JavierJF Aug 6, 2019
8b8d908
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Aug 6, 2019
664fce8
GPII-3780: Changed preferences for 'test-user' to change to different…
JavierJF Aug 14, 2019
9a509bd
Merge branch 'stegru/GPII-3853' into GPII-4214
javihernandez Nov 7, 2019
85e8de4
Merge branch 'JavierJF/GPII-3780' into GPII-4214
javihernandez Nov 7, 2019
b6d498b
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Nov 19, 2019
0505a0f
Merge branch 'JavierJF/GPII-4231' into GPII-4214
javihernandez Nov 21, 2019
9891321
Merge branch 'stegru/GPII-3853' into GPII-4214
javihernandez Nov 21, 2019
064c6b4
Merge remote-tracking branch 'upstream/master' into GPII-3572
stegru Nov 22, 2019
db02ca4
GPII-3572: Made the log file initialisation pleasant
stegru Nov 22, 2019
b24cd0d
Merge remote-tracking branch 'upstream/master' into GPII-3572
stegru Dec 3, 2019
93925ad
GPII-3572: Made the log file initialisation pleasant
stegru Nov 22, 2019
a526bd8
Merge branch 'GPII-3572' into GPII-3853+3572
stegru Dec 3, 2019
a239f03
GPII-3852: Fixed merge of 3572
stegru Dec 4, 2019
80950ec
GPII-3852: Fixed merge of 3572 (2)
stegru Dec 4, 2019
9b3bf12
Merge branch 'stegru/GPII-3853' into GPII-4214.GPII-3572
javihernandez Dec 4, 2019
6a3290e
GPII-3852: Fixed merge of 3572 (missing grade name in test)
stegru Dec 4, 2019
1b707a2
GPII-3852: Fixed merge of 3572 (fixed unit test)
stegru Dec 4, 2019
242fc6b
GPII-3852: Fixed merge of 3572 Moved duration EventLogTests.js tests
stegru Dec 4, 2019
cbe2678
Merge branch 'stegru/GPII-3853' into GPII-4214.GPII-3572
javihernandez Dec 5, 2019
c233b92
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Dec 18, 2019
4231d15
Merge branch 'stegru/GPII-3853' into GPII-4214.GPII-3572
javihernandez Dec 19, 2019
fde4347
GPII-4214.GPII-3572: Revert "Revert "Merge branch 'GPII-4231'""
javihernandez Jan 8, 2020
b940b2c
GPII-3853: Fixed some fields which where incorrectly being stored as …
stegru Jan 8, 2020
3984def
Merge remote-tracking branch 'upstream/master' into GPII-3853
stegru Jan 9, 2020
d5575a7
Merge branch 'stegru/GPII-3853' into GPII-4214.GPII-3572
javihernandez Jan 10, 2020
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
25 changes: 17 additions & 8 deletions gpii/node_modules/eventLog/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gpii/node_modules/eventLog/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

183 changes: 121 additions & 62 deletions gpii/node_modules/eventLog/src/eventLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

var fluid = require("infusion");
var fs = require("fs"),
path = require("path"),
moment = require("moment"),
net = require("net");

Expand All @@ -39,9 +38,6 @@ fluid.defaults("gpii.eventLog", {
},
settingsDir: {
type: "gpii.settingsDir"
},
metrics: {
type: "gpii.metrics"
}
},
invokers: {
Expand All @@ -51,23 +47,41 @@ fluid.defaults("gpii.eventLog", {
},
logError: "gpii.eventLog.logError",
getGpiiSettingsDir: "{settingsDir}.getGpiiSettingsDir",
getLogFile: "gpii.eventLog.getLogFile",
getVersion: "gpii.eventLog.getVersion"
getVersion: "gpii.eventLog.getVersion",
setState: {
funcName: "gpii.eventLog.setState",
args: ["{eventLog}", "{arguments}.0", "{arguments}.1"] // name, value
}
},
members: {
// The installation ID
installationID: "@expand:{that}.installID.getInstallID()",
version: "@expand:{that}.getVersion()",
sequence: 0,
// Buffered log lines while there's not log server connection
logBuffer: [],
logLevel: fluid.logLevel.INFO,
// Maximum number of lines to buffer.
maxBufferlength: 0xfff
maxBufferlength: 0xfff,
// A TCP socket to send the log entries to (filebeat service).
logServer: {
host: null,
port: null
},
// A file to write the log entries to.
logPath: null,
// Data to include in every log entry.
eventData: {
// The installation ID
installID: "@expand:{that}.installID.getInstallID()",
version: "@expand:{that}.getVersion()",
sessionID: undefined,
gpiiKey: undefined
},
// The start times for events which require durations to be recorded.
eventTimes: {}
},
listeners: {
"onCreate.logFile": {
func: "gpii.eventLog.getLogFile",
args: ["{that}"]
func: "gpii.eventLog.initLogDestination",
args: ["{that}", "{that}.options.logDestination"]
},
"onCreate.log": {
func: "gpii.eventLog.logStartStop",
Expand All @@ -78,10 +92,22 @@ fluid.defaults("gpii.eventLog", {
args: ["{that}", "stop"]
}
},

logDestination: "tcp://127.0.0.1:51481"
// File path, or tcp://host:port
logDestination: null
});

/**
* A log event
* @typedef {Object} LogEvent
* @property {String} module The area of GPII the event is from.
* @property {String} event The name of the event.
* @property {String} data [optional] Extra information about the event.
* @property {Object} level The severity of the event (from fluid.logLevelsSpec, default: fluid.INFO).
* @property {String} version The eventLog module version. (automatically added)
* @property {String} timestamp Current time of the event. (automatically added)
* @property {String} sequence Ordered unique identifier to the event. (automatically added)
*/

/**
* Returns the actual date and time, as a string, in ISO 8601 format with the localtime + offset from UTC.
* eg: '2018-07-13T13:03:03.863+01:00'
Expand Down Expand Up @@ -125,7 +151,7 @@ gpii.eventLog.logStartStop = function (that, state) {
* @param {String} event - Name of the event.
* @param {Any} [data] - [optional] Event specific data.
* @param {Object} level -[optional] Level of the log, see fluid.logLevelsSpec [FATAL,FAIL,WARN,IMPORTANT,INFO,TRACE].
* @return {Object} The log object.
* @return {LogEvent} The log object.
*/
gpii.eventLog.createLogObject = function (moduleName, event, data, level) {
var eventObject = {
Expand Down Expand Up @@ -184,8 +210,11 @@ gpii.eventLog.logError = function (that, moduleName, errType, err, level) {
if (err instanceof Error) {
// Error doesn't serialise
data.error = {};
fluid.each(Object.getOwnPropertyNames(err), function (a) {
data.error[a] = err[a];
fluid.each(Object.getOwnPropertyNames(err), function (source) {
// Ensure the first character of the field is lowercase - "Message" vs "message" was causing a duplicate
// field during the analysis.
var dest = source.charAt(0).toLowerCase() + source.slice(1);
data.error[dest] = err[source];
});
} else if (fluid.isPlainObject(err, true)) {
data.error = Object.assign({}, err);
Expand Down Expand Up @@ -228,73 +257,86 @@ gpii.eventLog.gotError = function (err, errType) {
fluid.onUncaughtException.addListener(gpii.eventLog.gotError, "gpii-eventLog");

/**
* Gets the path of the new log file for this instance of gpii.
* It can use one of the following environment variables to override the configured:
* GPII_EVENT_LOG: The path to the log file (a file, or tcp://<host>:<port>).
* GPII_EVENT_LOG_DIRECTORY: A directory where per-instance logs are kept
* Parses the log path (which can be overridden by the GPII_EVENT_LOG environment variable), and sets either the
* logServer or logPath member.
*
* @param {Component} that - The gpii.eventLog instance.
* @return {String} The path to the new log file.
* @param {String} logPath - The path to the log file (a file, or a tcp socket in the format of `tcp://<host>:<port>`).
*/
gpii.eventLog.getLogFile = function (that) {
var logPath;
if (!process.env.GPII_EVENT_LOG_DIRECTORY) {
logPath = process.env.GPII_EVENT_LOG || that.logFilePath || that.options.logDestination;
}
gpii.eventLog.initLogDestination = function (that, logPath) {
logPath = process.env.GPII_EVENT_LOG || logPath;

if (logPath) {
if (logPath.startsWith("tcp:")) {
var m = /tcp:\/*([^:]+):([0-9]+)/.exec(logPath);
if (m) {
that.logHost = m[1];
that.logPort = m[2];
that.logFilePath = null;
}
} else {
that.logHost = null;
that.logFilePath = logPath;
}
var match = logPath && /tcp:\/*([^:]+):([0-9]+)/.exec(logPath);
if (match) {
that.logServer.host = match[1];
that.logServer.port = match[2];
} else {
that.logHost = null;
var startupTime = Date.now();
var gpiiSettingsDir = process.env.GPII_EVENT_LOG_DIRECTORY || that.getGpiiSettingsDir();
that.logFilePath = path.join(gpiiSettingsDir, "gpii-" + gpii.journal.formatTimestamp(startupTime) + ".log");
that.logPath = logPath;
}

var dest = that.logHost ? ("tcp://" + that.logHost + ":" + that.logPort) : that.logFilePath;
var dest = that.logServer.host ? ("tcp://" + that.logServer.host + ":" + that.logServer.port) : that.logPath;
fluid.log(fluid.logLevel.IMPORTANT, "Writing event log to " + dest);

return that.logFilePath;
};

/**
* Writes an event to the log file.
*
* @param {Component} that - The gpii.eventLog instance.
* @param {Object} level - Level of the log, see fluid.logLevelsSpec [FATAL,FAIL,WARN,IMPORTANT,INFO,TRACE].
* @param {Object} event - The object. This will be modified to what has been sent to the log, adding the installID and
* @param {LogEvent} event - The object. This will be modified to what has been sent to the log, adding the installID and
* timestamp fields.
*/
gpii.eventLog.writeLog = function (that, level, event) {
var intLevel = gpii.eventLog.checkLevel(level);
event.level = intLevel.value;
var eventLevel = gpii.eventLog.checkLevel(level);
event.level = eventLevel.value;

// Log to console before the installation ID and timestamp are added (no one wants to see it).
fluid.log(fluid.logLevel.TRACE, event);
gpii.eventLog.recordDuration(that, event);

event.installID = that.installationID;
Object.assign(event, that.eventData);
event.timestamp = gpii.eventLog.getTimestamp();
event.version = that.version;
event.sequence = that.sequence++;

var logLine = JSON.stringify(event) + "\n";
if (eventLevel.priority <= that.logLevel.priority) {
var logLine = JSON.stringify(event) + "\n";

if (that.logServer.host && that.logServer.port) {
gpii.eventLog.writeLogTcp(that, logLine);
}

if (that.logHost && that.logPort) {
gpii.eventLog.writeLogTcp(that, logLine);
if (that.logPath) {
fs.appendFileSync(that.logPath, logLine);
}
}
};

if (that.logFilePath) {
fs.appendFileSync(that.logFilePath, logLine);
/**
* Handles the timing of a pair of duration events.
*
* Some events can be paired into having a duration. For example, tooltip-shown and tooltip-hidden. The timestamp for
* the start event is recorded, so when the end event is seen the duration is calculated and added to the event data.
*
* @param {Component} that The gpii.eventLog instance.
* @param {LogEvent} event The event.
*/
gpii.eventLog.recordDuration = function (that, event) {
var endEvent = that.options.durationEvents[event.event];
if (endEvent) {
// This is the start of a pair of duration events.
if (!that.eventTimes[endEvent]) {
that.eventTimes[endEvent] = [];
}
that.eventTimes[endEvent].push(process.hrtime());
} else {
var startTimes = that.eventTimes[event.event];
var startTime = startTimes && startTimes.pop();
if (startTime) {
// This is the ending of a pair of duration events.
if (!event.data) {
event.data = {};
}
var memberName = event.data.hasOwnProperty("duration") ? "duration_auto" : "duration";
event.data[memberName] = process.hrtime(startTime)[0];
}
}
};

Expand Down Expand Up @@ -334,7 +376,7 @@ gpii.eventLog.connectLog = function (that) {

// Connect to the server.
that.logSocket = new net.Socket();
that.logSocket.connect(that.logPort, that.logHost, function () {
that.logSocket.connect(that.logServer.port, that.logServer.host, function () {
gpii.eventLog.connectLog.lastError = null;
fluid.log("Connected to log server");
// Send the initial data.
Expand Down Expand Up @@ -368,12 +410,29 @@ gpii.eventLog.connectLog = function (that) {
* Sets INFO as default loglevel
*
* @param {Object} level - Level to check, can be a string that represents the value or a property of fluid.logLevel.
* @return {Integer} A valid fluid.logLevel, with INFO as default.
* @return {Object} A valid fluid.logLevel, with INFO as default.
*/
gpii.eventLog.checkLevel = function (level) {
var togo;
if (typeof level === "string" && level in fluid.logLevelsSpec) {
return fluid.logLevel[level];
togo = fluid.logLevel[level];
} else {
togo = fluid.isLogLevel(level) && level;
}
return togo || fluid.logLevel.INFO;
};

/**
* Specifies a field which gets logged with every subsequent event.
*
* @param {Component} that The gpii.eventLog instance.
* @param {String} name The name of the field.
* @param {Object} value The field value. undefined or null will remove the field.
*/
gpii.eventLog.setState = function (that, name, value) {
if (value === undefined || value === null) {
delete that.eventData[name];
} else {
return fluid.isLogLevel(level) ? level : fluid.logLevel.INFO;
that.eventData[name] = value;
}
};
Loading