@ubisense/smartspace.logview

1.0.1 • Public • Published

LogView

This is the Ubisense LogView javascript client side library.

LogView allows client applications to subscribe to live platform log messages from SmartSpace® and other integrated log sources, such as ACS. LogView uses SignalR, and this library is a simple wrapper around a SignalR client.

Full documentation of LogView is currently maintained on Ubisense Docs.

Getting Started

Create an LogView instance, start it, and then call .requestLog to subscribe to particular matching log messages.

...
let lv = new LogView(anon);
lv.setTarget((data) => { console.log(data.message); });
lv.start().then(() => {
	lv.requestLog('SmartSpace','/warning|log_view/');
	lv.requestLog('SmartSpace','ls_');
	lv.requestLog('ACS','Fill','6i2CGhIbuqb1JT7G00000G000uf:ACS::AssemblyLine');
});
...

Simple Usage

The constructor takes a single argument which can be either:

  • Missing, in which case the class connects to the authenticated hub, and the user must be logged in to the SmartSpace web site. The user must be a member of the System.Web.LogViewer role.
  • A boolean, in which case true means to connect to the anonymous hub, which does not authenticate the user. The anonymous user must be a member of the System.Web.LogViewer role. If false, uses the authenticated hub.
  • A string, in which case this is the URL of the hub to which LogView will connect.

The setTarget method takes either:

  • A function, in which case the function is called with a single argument which is the log item.
  • An object, in which case the object is assigned each log item as it arrives.
  • An object and a string property name, in which case obj[prop] is assigned each log item as it arrives.

The latter two methods are intended for use in reactive frameworks. In any case the log values delivered by LogView are objects with the following form:

{
	"when": a Date object, when the log message was raised,
	"source": the source string, such as "SmartSpace" or "ACS",
	"logObject": the object id of the log source, if there is one,
	"message": the log message itself
}

The start method attempts to connect to the hub to start receiving log messages. It returns a promise, so .then can be used to request logs on success, or .catch can be used to respond to connection errors.

The requestLog method subscribes for log messages. The LogView instance must have been started before it is called. It takes up to three arguments:

  • The source, which is currently either "SmartSpace" or "ACS"
  • The filter to apply, which is a string to match in the message line. If the filter starts and ends with '\' then it is treated as an ECMAScript regex pattern to match in the message.
  • The log object, only used by "ACS" sources. This is the object id of the log object to subscribe to, such as an ACS Assembly Line or Device.

The clearLogs method removes all current subscriptions.

The logMessage method can be used to generate a SmartSpace log from a javascript client. The first parameter is the message to send, and the second parameter is the monitor stream to send it on, with "log_view" the default if not specified.

Package Sidebar

Install

npm i @ubisense/smartspace.logview

Weekly Downloads

0

Version

1.0.1

License

BSD-2-Clause

Unpacked Size

266 kB

Total Files

9

Last publish

Collaborators

  • rcurwen