Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: remoting/webapp/crd/js/native_message_host_log_message_handler.js

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/it2me_host_facade.js ('k') | remoting/webapp/files.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 /**
6 * @fileoverview
7 * Class to handle debug log messages sent by either the It2Me or Me2Me native
8 * messaging hosts.
9 */
10
11 'use strict';
12
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
15
16 (function() {
17
18 /**
19 * @constructor
20 */
21 remoting.NativeMessageHostDebugMessageHandler = function() {
22 };
23
24 /**
25 * Handle debug messages..
26 *
27 * @param {Object} message
28 * @return {boolean} True if the message was handled.
29 */
30 remoting.NativeMessageHostDebugMessageHandler.prototype.handleMessage =
31 function(message)
32 {
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);
53 };
54 return true;
55 }
56 return false;
57 };
58
59 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/it2me_host_facade.js ('k') | remoting/webapp/files.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698