logging.js - The client-side portion of Gate One's Logging plugin.
Creates a new log destination named, name that calls function dest like so:
dest(<log message>);
Example usage:
GateOne.Logging.addDestination('screen', GateOne.Visual.displayMessage);
Note
The above example is kind of fun. Try it in your JavaScript console!
Creates a logItem element using logObj and places it in container.
delay controls how long it will wait before using a CSS3 effect to move it into view.
Creates the logging panel (just the empty shell of it).
Converts a Date() object into string suitable for logging. e.g. 2011-05-29 13:24:03
Opens a new window displaying the (flat) log contained within message if there are no errors reported.
Displays the information about the log file, logFile in the metadata area of the log viewer.
Opens a new window playing back the log contained within message if there are no errors reported.
Calculates and returns the number of log items that will fit in the given element (elem). elem may be a DOM node or an element ID (string).
Adds message['log'] to GateOne.Logging.serverLogs and places it into the view.
Sets the header of the log viewer and displays a message to indicate we're done loading.
Creates the log viewer panel and registers the following WebSocket actions:
GateOne.Net.addAction('logging_log', GateOne.Logging.incomingLogAction);
GateOne.Net.addAction('logging_logs_complete', GateOne.Logging.incomingLogsCompleteAction);
GateOne.Net.addAction('logging_log_flat', GateOne.Logging.displayFlatLogAction);
GateOne.Net.addAction('logging_log_playback', GateOne.Logging.displayPlaybackLogAction);
After GateOne.Logging.serverLogs has been populated this function will redraw the view depending on sort and pagination values.
If forceUpdate empty out GateOne.Logging.serverLogs and tell the server to send us a new list.
Sets up the pagination for the given array of logItems and returns the pagination node.
If page is given, the pagination will highlight the given page number and adjust prev/next accordingly.
Logs the given msg using all of the functions in GateOne.Logging.destinations after being prepended with the date and a string indicating the log level (e.g. "692011-10-25 10:04:28 INFO <msg>") if level is determined to be greater than the value of GateOne.Logging.level. If the given level is not greater than GateOne.Logging.level msg will be discarded (noop).
level can be provided as a string, an integer, null, or be left undefined:
If an integer, an attempt will be made to convert it to a string using GateOne.Logging.levels but if this fails it will use "lvl:<integer>" as the level string. If a string, an attempt will be made to obtain an integer value using GateOne.Logging.levels otherwise GateOne.Logging.level will be used (to determine whether or not the message should actually be logged). If undefined, the level will be set to GateOne.Logging.level. If null (as opposed to undefined), level info will not be included in the log message.
If destination is given (must be a function) it will be used to log messages like so: destination(message, levelStr). The usual conversion of msg to message will apply.
Logs the given msg to the browser's JavaScript console. If level is provided it will attempt to use the appropriate console logger (e.g. console.warn()).
Note
Original version of this function is from: MochiKit.Logging.Logger.prototype.logToConsole.
Tells the server to open logFile for playback via the 'logging_get_log_flat' server-side WebSocket action (will end up calling displayFlatLogAction().
Tells the server to open logFile for playback via the 'logging_get_log_playback' server-side WebSocket action (will end up calling displayPlaybackLogAction().
If where is given and it is set to 'preview' the playback will happen in the log_preview iframe.
Removes the given log destination (name) from GateOne.Logging.destinations
Tells the server to open logFile rendered as a self-contained recording (via the 'logging_get_log_file' WebSocket action) and send it back to the browser for saving (using the 'save_file' WebSocket action).
Sets the log level to an integer if the given a string (e.g. "DEBUG"). Sets it as-is if it's already a number.
An associative array of functions that are used to sort logs. When the user clicks on one of the sorting options it assigns one of these functions to GateOne.Logging.sortfunc() which is then applied like so:
logs.sort(GateOne.Logging.sortfunc);
Sorts logs alphabetically using the title (connect_string).
Sorts logs according to their size.
Sorts logs by date (start_date) followed by alphabetical order of the title (connect_string).
Reverses the order of the logs array.
logging.py - A plugin for Gate One that provides logging-related functionality.
This Python plugin file implements the following hooks:
hooks = {
'WebSocket': {
'logging_get_logs': enumerate_logs,
'logging_get_log_flat': retrieve_log_flat,
'logging_get_log_playback': retrieve_log_playback,
'logging_get_log_file': save_log_playback,
}
}
Returns the frames of golog_path as a list that can be used with the playback_log.html template.
If limit is given, only return that number of frames (e.g. for preview)
Calls _enumerate_logs() via a multiprocessing.Process so it doesn't cause the IOLoop to block.
Log objects will be returned to the client one at a time by sending 'logging_log' actions to the client over the WebSocket (self).
Enumerates all of the user's logs and sends the client a "logging_logs" message with the result.
If limit is given, only return the specified logs. Works just like MySQL: limit="5,10" will retrieve logs 5-10.
Calls _retrieve_log_flat() via a multiprocessing.Process so it doesn't cause the IOLoop to block.
Parameters: |
|
---|
Here's the details on settings:
Parameters: |
|
---|
Writes the given log_filename to queue in a flat format equivalent to:
./logviewer.py --flat log_filename
settings - A dict containing the log_filename, colors, and theme to use when generating the HTML output.
Calls _retrieve_log_playback() via a multiprocessing.Process so it doesn't cause the IOLoop to block.
Writes a JSON-encoded message to the client containing the log in a self-contained HTML format similar to:
./logviewer.py log_filename
settings - A dict containing the log_filename, colors, and theme to use when generating the HTML output.
Parameters: |
|
---|
The output will look like this:
{
'result': "Success",
'log': <HTML rendered output>,
'metadata': {<metadata of the log>}
}
It is expected that the client will create a new window with the result of this method.
Calls _save_log_playback() via a multiprocessing.Process so it doesn't cause the IOLoop to block.
Writes a JSON-encoded message to the client containing the log in a self-contained HTML format similar to:
./logviewer.py log_filename
The difference between this function and _retrieve_log_playback() is that this one instructs the client to save the file to disk instead of opening it in a new window.
Parameters: |
|
---|
The output will look like this:
{
'result': "Success",
'data': <HTML rendered output>,
'mimetype': 'text/html'
'filename': <filename of the log recording>
}
It is expected that the client will create a new window with the result of this method.