Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / third_party / Promises / polyfill / util / console.js
1 (function(global) {
2   if (typeof global.console != "undefined") {
3     return;
4   }
5
6   var toString = function(item) {
7     var t = (typeof item);
8     if (t == "undefined") {
9       return "undefined";
10     } else if (t == "string") {
11       return item;
12     } else if (t == "number") {
13       return item + "";
14     } else if (item instanceof Array) {
15       return item + "";
16     }
17     return item + "";
18   }
19
20   // A minimal console
21   var log = function(hint, args){
22     var r = "";
23     var al = args.length;
24     r += ((hint ? hint + ":" : "") + (args[0] ? toString(args[0]) : ""));
25     for(var i = 1; i < al; i++){
26       r += (" " + toString(args[i]));
27     }
28     print(r);
29   };
30
31   var makeLogger = function(hint) {
32     return function() {
33       log(hint, Array.prototype.slice.call(arguments, 0));
34     };
35   }
36
37   // Intentionally define console in the global namespace
38   global.console = {
39     log:        makeLogger(""),
40     error:      makeLogger("ERROR"),
41     warn:       makeLogger("WARN"),
42     trace:      makeLogger("TRACE"),
43     time:       function() {},
44     timeEnd:    function() {},
45     profile:    function() {},
46     profileEnd: function() {},
47   };
48
49 })(this);