forked from mapsplugin/cordova-plugin-googlemaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
masashiGMS
committed
Nov 13, 2013
1 parent
05c9fd7
commit 6ec8dc9
Showing
24 changed files
with
2,188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
cordova.define('cordova/plugin_list', function(require, exports, module) { | ||
module.exports = [] | ||
module.exports = [ | ||
{ | ||
"file": "plugins/org.apache.cordova.console/www/console-via-logger.js", | ||
"id": "org.apache.cordova.console.console", | ||
"clobbers": [ | ||
"console" | ||
] | ||
}, | ||
{ | ||
"file": "plugins/org.apache.cordova.console/www/logger.js", | ||
"id": "org.apache.cordova.console.logger", | ||
"clobbers": [ | ||
"cordova.logger" | ||
] | ||
} | ||
] | ||
}); |
188 changes: 188 additions & 0 deletions
188
platforms/android/assets/www/plugins/org.apache.cordova.console/www/console-via-logger.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
cordova.define("org.apache.cordova.console.console", function(require, exports, module) {/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
*/ | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
var logger = require("./logger"); | ||
var utils = require("cordova/utils"); | ||
|
||
//------------------------------------------------------------------------------ | ||
// object that we're exporting | ||
//------------------------------------------------------------------------------ | ||
var console = module.exports; | ||
|
||
//------------------------------------------------------------------------------ | ||
// copy of the original console object | ||
//------------------------------------------------------------------------------ | ||
var WinConsole = window.console; | ||
|
||
//------------------------------------------------------------------------------ | ||
// whether to use the logger | ||
//------------------------------------------------------------------------------ | ||
var UseLogger = false; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Timers | ||
//------------------------------------------------------------------------------ | ||
var Timers = {}; | ||
|
||
//------------------------------------------------------------------------------ | ||
// used for unimplemented methods | ||
//------------------------------------------------------------------------------ | ||
function noop() {} | ||
|
||
//------------------------------------------------------------------------------ | ||
// used for unimplemented methods | ||
//------------------------------------------------------------------------------ | ||
console.useLogger = function (value) { | ||
if (arguments.length) UseLogger = !!value; | ||
|
||
if (UseLogger) { | ||
if (logger.useConsole()) { | ||
throw new Error("console and logger are too intertwingly"); | ||
} | ||
} | ||
|
||
return UseLogger; | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.log = function() { | ||
if (logger.useConsole()) return; | ||
logger.log.apply(logger, [].slice.call(arguments)); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.error = function() { | ||
if (logger.useConsole()) return; | ||
logger.error.apply(logger, [].slice.call(arguments)); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.warn = function() { | ||
if (logger.useConsole()) return; | ||
logger.warn.apply(logger, [].slice.call(arguments)); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.info = function() { | ||
if (logger.useConsole()) return; | ||
logger.info.apply(logger, [].slice.call(arguments)); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.debug = function() { | ||
if (logger.useConsole()) return; | ||
logger.debug.apply(logger, [].slice.call(arguments)); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.assert = function(expression) { | ||
if (expression) return; | ||
|
||
var message = logger.format.apply(logger.format, [].slice.call(arguments, 1)); | ||
console.log("ASSERT: " + message); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.clear = function() {}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.dir = function(object) { | ||
console.log("%o", object); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.dirxml = function(node) { | ||
console.log(node.innerHTML); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.trace = noop; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.group = console.log; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.groupCollapsed = console.log; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.groupEnd = noop; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.time = function(name) { | ||
Timers[name] = new Date().valueOf(); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.timeEnd = function(name) { | ||
var timeStart = Timers[name]; | ||
if (!timeStart) { | ||
console.warn("unknown timer: " + name); | ||
return; | ||
} | ||
|
||
var timeElapsed = new Date().valueOf() - timeStart; | ||
console.log(name + ": " + timeElapsed + "ms"); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.timeStamp = noop; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.profile = noop; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.profileEnd = noop; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.count = noop; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.exception = console.log; | ||
|
||
//------------------------------------------------------------------------------ | ||
console.table = function(data, columns) { | ||
console.log("%o", data); | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
// return a new function that calls both functions passed as args | ||
//------------------------------------------------------------------------------ | ||
function wrappedOrigCall(orgFunc, newFunc) { | ||
return function() { | ||
var args = [].slice.call(arguments); | ||
try { orgFunc.apply(WinConsole, args); } catch (e) {} | ||
try { newFunc.apply(console, args); } catch (e) {} | ||
}; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// For every function that exists in the original console object, that | ||
// also exists in the new console object, wrap the new console method | ||
// with one that calls both | ||
//------------------------------------------------------------------------------ | ||
for (var key in console) { | ||
if (typeof WinConsole[key] == "function") { | ||
console[key] = wrappedOrigCall(WinConsole[key], console[key]); | ||
} | ||
} | ||
}); |
Oops, something went wrong.