-
Notifications
You must be signed in to change notification settings - Fork 2
ActionLogger
The ActionLogger provides an easy mechanism for logging students' activities in Go-Lab. Since the Go-Lab portal is built on top of Apache Shindig, an OpenSocial container implementation, and since OpenSocial makes us of the Activity Streams specifications for activity logging, user action logging in Go-Lab is handled through Acitivity Streams as well.
The ActionLogger requires a MetadataHandler at construction time, and can be configured towards various "logging targets", i.e. endpoints to receive the occurring action log information.
The actual use of the ActionLogger at runtime mostly consists of repeatedly calling the function log(verb, object) which creates an ActivityStream object from the given information, and adds information from the MetadataHandler. The ActivityStream object is then relayed to the specified logging target.
The Activity Streams format utilises an "actor-verb-object" metaphor, with optional additional elements like target, generator, and provider (see also MetadataHandler). During typical tool usage in Go-Lab, most of these elements remain static (over the course of an activity), leaving only the "verb" and the "object" to be used as a parameter in the ActionLogger's function calls.
Typically, each tool instance creates and uses its own ActionLogger instance, along with its own MetadataHandler.
An example action log object can be found [here](example action log).
// assuming we have created a MetadataHandler before var actionLogger = new ut.commons.actionlogging.ActionLogger(metadataHandler); actionLogger.setLoggingTargetByName("opensocial");
In order to conveniently change the loggers behaviour (e.g., for development, testing or production use), the action logger can be configured towards various 'targets' (see API below). Currently, five logging targets are implemented:
- "null": Discards all incoming action logs, doing nothing.
- "console": Prints the full Activity Streams object to the JavaScript console.
- "consoleShort": Prints only the verb, object and object identifier to the console.
- "dufftown": Relays the Activity Streams objects directly to a Learning Analytics backend server of one the project consortium's member.
- "opensocial": Relays the Activity Streams object to the underlying Go-Lab platform, where it can be processed and relayed further.
###API
#### setLoggingTarget(loggingTarget: function(activityStreamObject: object): void): void Sets the logging target in the ActionLogger. The logging target is a function that processes (and typically relays) an Activity Streams object.
`loggingTarget: function(activityStreamObject: object): void` A function that accepts and processes an Activity Streams object. Available implementations are e.g. consoleLogging() or opensocialLogging(), but you can also pass custom functions.
#### setLoggingTargetByName(loggingTargetName: string): void Sets the logging target in the ActionLogger, using a string representation of the implemented logging targets (see above). This function is convenient to use when the setting for the logging target is e.g. read from a configuration file.
`loggingTargetName: string` The name of the logging target to be set. Currently, accepted values are "null", "console", "consoleShort", "dufftown", and "opensocial". Any other value will be interpreted as "null".
#### log(verb: string, logObject: object): void Creates an Activity Streams object from the given verb, object and from the information in the MetadataHandler, and calls the logging target function with this Activity Streams object.
`verb: string` A textual representation of the activity, in the fashion of a verb. Typical examples would be "create", "update", or "remove".
`logObject: object` A JSON object describing the "object" of an activity, following the Activity Streams specifications. Typical examples would be a concept in a Concept Map, or a hypothesis from the Hypothesis Scratchpad tool.