Bug 1049409

Summary: [RFE] Persistent client-side logging infrastructure
Product: [oVirt] ovirt-engine Reporter: Vojtech Szocs <vszocs>
Component: RFEsAssignee: Vojtech Szocs <vszocs>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Novotny <pnovotny>
Severity: medium Docs Contact:
Priority: unspecified    
Version: ---CC: bugs, gklein, iheim, mgoldboi, pstehlik, rbalakri, yeylon, ykaul
Target Milestone: ovirt-3.6.0-rcKeywords: FutureFeature
Target Release: 3.6.0Flags: rule-engine: ovirt-3.6.0+
ylavi: planning_ack+
rule-engine: devel_ack+
pnovotny: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Added the ability to persist UI log messages in the browser, utilizing HTML5 Local Storage API [1]. [1] https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API Unless the user manually clears browser's web storage content [2], UI logs are persisted across browser restarts. [2] http://www.ghacks.net/2015/02/05/how-to-clear-web-storage-in-your-browser-of-choice/ This feature allows better diagnosis of UI related problems. To inspect UI logs in Firefox: - navigate to oVirt/RHEV web application - open developer tools (Ctrl+Shift+I) - select Console tab - type `inspect(localStorage)` To inspect UI logs in Chrome: - open developer tools (Ctrl+Shift+I) - select Resources tab - select Local Storage and pick oVirt/RHEV Engine origin Log records are stored as a ring buffer [3]: "First In, First Out" (FIFO) data structure with fixed capacity (100). When adding new element into full buffer, the oldest element is replaced with newly added element. [3] https://en.wikipedia.org/wiki/Circular_buffer Actual log records are stored under key `ENGINE_{WebAdmin,UserPortal}_Log_{N}` where N is a number ranging from 0 (inclusive) to 100 (exclusive). Keys `ENGINE_{WebAdmin,UserPortal}_LogHead` and `ENGINE_{WebAdmin,UserPortal}_LogSize` are used to store internal state of the ring buffer. See Pavel's comment #3 for examples on specific keys and their values.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-10 12:50:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: UX RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1210446    

Description Vojtech Szocs 2014-01-07 14:44:03 UTC
At the moment, client-side logging works only when debugging GWT application via Development Mode [1]:

  import java.util.logging.Logger; // GWT emulates java.util.logging classes
  static final Logger logger = Logger.getLogger(Anything.class.getName());
  logger.info("Example log entry");

[1] http://www.ovirt.org/DebugFrontend#GWT_Development_Mode

When compiling GWT application for production use, GWT compiler removes such client-side logging statements from resulting JavaScript code.

Compared to Development Mode, GWT application compiled for production use has following inconveniences:
a, client-side logs are not available
b, runtime errors are silently ignored [2] - user has to open browser-specific error console to inspect any runtime errors

[2] currently there is no global error handler to catch runtime errors, which means GUI can be broken whenever uncaught exception escapes from application code (severity of GUI breakage depends on place where exception occured and code that was meant to normally execute after it)

This RFE targets above mentioned inconveniences:
a, provide support for persisting client-side logs locally in the browser, utilizing existing ClientStorage abstraction
b, add global error handler that persists uncaught exceptions and prevents them from escaping application code

In future, we can consider follow-up improvements (out of scope for this BZ, unless we decide otherwise):
* modify java.util.logging emulation to utilize persistent client-side logging support
* implement "Show Errors" GUI dialog to visualize collected runtime errors
* propagate collected runtime errors to server (engine-ui.log)

References:
http://stackoverflow.com/questions/3028521/gwt-setuncaughtexceptionhandler

Comment 1 Vojtech Szocs 2015-05-19 10:10:48 UTC
Update of BZ description (comment #0):

- client-side logging code is retained also in production (non-debug) GWT application builds

- patch [1] ensures that client-side log records are persisted in browser via HTML5 Web Storage API

- see commit message [1] for list of all effective client-side log handlers

[1] https://gerrit.ovirt.org/#/c/25444/

Comment 2 Max Kovgan 2015-06-28 14:12:11 UTC
ovirt-3.6.0-3 release

Comment 3 Pavel Novotny 2016-02-02 16:39:05 UTC
Verified in rhevm-3.6.3-0.1.el6.noarch (build 3.6.3-1 RC1).

User Portal and Webadmin now store client-side log messages to browser's local storage.

The pattern for keys names is following:
ENGINE_{UserPortal,WebAdmin}_Log_{$index,LogHead,LogSize}

Legend:
ENGINE_WebAdmin_Log_$index
- a single "log record", $index value is within range (0, ENGINE_WebAdmin_LogSize - 1)
ENGINE_WebAdmin_LogSize
- number of "log records", maximum is 100, after reaching the limit, messages are rotated/overwritten
ENGINE_WebAdmin_LogHead
- number of the latest "log record", not index
- the latest "log record" key name is equal to ENGINE_WebAdmin_Log_$(ENGINE_WebAdmin_LogHead-1)


Excerpt from my browser storage:

ENGINE_WebAdmin_LogHead
	"23"
ENGINE_WebAdmin_LogSize
	"100"
ENGINE_WebAdmin_Log_0
	"Mon Feb 01 17:13:17 GMT+100 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager
	INFO: Invoking event handler function [HostSelectionChange] for plugin [TestPlugin]"
ENGINE_WebAdmin_Log_1
	"Mon Feb 01 17:13:17 GMT+100 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager
	INFO: Invoking event handler function [HostSelectionChange] for plugin [redhat_support_plugin_rhev]"
ENGINE_WebAdmin_Log_10
	"Tue Feb 02 13:19:23 GMT+100 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager
	INFO: Plugin [redhat_support_plugin_rhev] reports in as ready"
ENGINE_WebAdmin_Log_11
	"Tue Feb 02 13:19:23 GMT+100 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager
	INFO: Plugin [TestPlugin] has registered the event handler object"
...
...
ENGINE_WebAdmin_Log_21
	"Tue Feb 02 13:55:09 GMT+100 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager
	INFO: Invoking event handler function [RestApiSessionAcquired] for plugin [TestPlugin]"
ENGINE_WebAdmin_Log_22
	"Tue Feb 02 13:55:09 GMT+100 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager
	INFO: Invoking event handler function [RestApiSessionAcquired] for plugin [redhat_support_plugin_rhev]"
ENGINE_WebAdmin_Log_23
	"Wed Jan 27 17:54:19 GMT+100 2016 org.ovirt.engine.ui.uicompat.EnumTranslator
	WARNING: trying to localize null, probable error. Exception is not thrown, returning 'N/A'"
ENGINE_WebAdmin_Log_24
	"Wed Jan 27 17:54:23 GMT+100 2016 org.ovirt.engine.ui.uicompat.EnumTranslator
	WARNING: trying to localize null, probable error. Exception is not thrown, returning 'N/A'"