OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
Sergey Ulanov
2015/08/16 23:22:02
2015
Jamie
2015/08/17 17:32:24
Done.
| |
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 })(); | |
OLD | NEW |