Update broken references to image assets
[chromium-blink-merge.git] / remoting / webapp / crd / js / native_message_host_log_message_handler.js
blobab5ff9fda42a42ccbb0713a1d9aa4817d5ab18eb
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 /**
6 * @fileoverview
7 * Class to handle debug log messages sent by either the It2Me or Me2Me native
8 * messaging hosts.
9 */
11 'use strict';
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
16 (function() {
18 /**
19 * @constructor
21 remoting.NativeMessageHostDebugMessageHandler = function() {
24 /**
25 * Handle debug messages..
27 * @param {Object} message
28 * @return {boolean} True if the message was handled.
30 remoting.NativeMessageHostDebugMessageHandler.prototype.handleMessage =
31 function(message)
33 /** @type {string} */
34 var type = base.getStringAttr(message, 'type', '');
35 switch (type) {
36 case '_debug_log':
37 var timestamp = base.timestamp();
38 var msg = base.getStringAttr(message, 'message', '<no message>');
39 var severity = base.getStringAttr(message, 'severity', 'log');
40 var file = base.getStringAttr(message, 'file', '<no file>');
41 var line = base.getNumberAttr(message, 'line', -1);
42 var location = file + ':' + line;
43 var css = 'color: gray; font-style: italic'
44 switch (severity) {
45 case 'error':
46 console.error('%s %s %c%s', timestamp, msg, css, location);
47 break;
48 case 'warn':
49 console.warn('%s %s %c%s', timestamp, msg, css, location);
50 break;
51 default:
52 console.log('%s %s %c%s', timestamp, msg, css, location);
54 return true;
56 return false;
59 })();