Namespace: log

airlock.log

Provides persistent logging capabilities.
Source:

Members

(static, readonly) LogLevel :number

Enum LogLevel
Type:
  • number
Properties:
Name Type Description
ALL number The least restrictive level.
DEBUG number For debugging purposes. More verbose than the Info level and less verbose than the Trace level.
INFO number Signifies verbose information. More verbose than the Warn level and less verbose than the Debug level.
WARN number Signifies a warning from e.g. an unexpected event.
ERROR number When an application error occurs.
FATAL number When the application is no longer able to function or is in an unreliable state. Highly restrictive logging.
NONE number Logging is disabled.
Source:

Methods

(static) debug(message, erroropt)

Writes a log entry at the LogLevel.DEBUG level. The log entry is not processed if the minimum log level is greater than the DEBUG level.
Parameters:
Name Type Attributes Description
message string The text content to write to the log.
error string <optional>
An error associated with the entry. Can be null.
Source:
See:
Example
airlock.log.debug("Message from my web page");

(static) deleteEntries(startDateopt, endDateopt) → {number}

Deletes the log entries via a Promise. Optionally, a date range can be specified using the startDate and endDate parameters. If supplied, only those entries that fall between startDate and endDate are deleted. If both startDate and endDate are undefined, all log entries are deleted.
Parameters:
Name Type Attributes Description
startDate Date <optional>
If supplied, only entries that were made after this date and time are deleted.
endDate Date <optional>
If supplied, only entries that were made prior to this date and time are deleted.
Source:
Returns:
The number of deleted log entries.
Type
number
Example
var endDate = new Date();
// Create a Date object that indicates the time one minute ago.
endDate.setMinutes(endDate.getMinutes() - 1);

// Delete Log Entries greater than 1 minute old.
airlock.log.deleteEntries(null, endDate)
		.then(function (value) {
			alert(`Deleted ${value} entries.`);
		}).catch(function (error) {
			alert(`Error ${error}`);
		});

(static) error(message, erroropt)

Writes a log entry at the LogLevel.ERROR level. The log entry is not processed if the minimum log level is greater than the ERROR level.
Parameters:
Name Type Attributes Description
message string The text content to write to the log.
error string <optional>
An error associated with the entry. Can be null.
Source:
See:
Example
airlock.log.info("Message from my web page", error);

(static) getEntries(startDateopt, endDateopt) → {Promise.<Array.<airlock.log.LogEntry>>}

Reads the log and returns the entries using a Promise. Optionally, a date range can be specified using the startDate and endDate parameters. If supplied, only those entries that fall between startDate and endDate are returned.
Parameters:
Name Type Attributes Description
startDate Date <optional>
If supplied, only entries that were made after this date and time are returned.
endDate Date <optional>
If supplied, only entries that were made prior to this date and time are returned.
Source:
Returns:
Resolves a list of log entries.
Type
Promise.<Array.<airlock.log.LogEntry>>
Example
var startDate = new Date();
// Create a Date object that indicates the time one minute ago.
startDate.setMinutes(startDate.getMinutes() - 1);

// Get Entries less than 1 minute old.
airlock.log.getEntries(startDate)
	.then(function (logEntries) {
		let text = "";
		for (let i = 0; i < logEntries.length; i++) {
			let entry = logEntries[i];
			text += getPropertyValues(entry) + "\n";
		}
		alert(text);
	}).catch(function(error) {
		alert(`Error ${error}`);
	});

(static) info(message, erroropt)

Writes a log entry at the LogLevel.INFO level. The log entry is not processed if the minimum log level is greater than the INFO level.
Parameters:
Name Type Attributes Description
message string The text content to write to the log.
error string <optional>
An error associated with the entry. Can be null.
Source:
See:
Example
airlock.log.info("Message from my web page");

(static) setMinLevel(level)

Sets the minimum log level
Parameters:
Name Type Description
level airlock.log.LogLevel Any log messages below this threshold are ignored.
Source:
Example
// Limit logging to warning message or higher.
airlock.log.setMinLevel(airlock.log.LogLevel.WARN);

(static) warn(message, erroropt)

Writes a log entry at the LogLevel.WARN level. The log entry is not processed if the minimum log level is greater than the WARN level.
Parameters:
Name Type Attributes Description
message string The text content to write to the log.
error string <optional>
An error associated with the entry. Can be null.
Source:
See:
Example
airlock.log.warn("Message from my web page", error);

Type Definitions

LogEntry

Properties:
Name Type Description
message string The text content of the log entry.
exception string The error associated with this entry. Can be undefined.
occuredUtc Date The time and date in universal time when this entry was written to the log.
logLevel airlock.log.LogLevel The log level of this entry.
url string The URL of the page or JavaScript file where the log entry was written.
The number line number in the file where the call to write to the log was made.
function string The name of the function where the log call took place.
Source: