/* * Copyright 2011 eBay Software Foundation * * Licensed 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. */ 'use strict'; function getConsole() { if (typeof console === 'undefined') { // probably IE and Developer Tools are not open return null; } if (!console.log.apply || !console.log.call) { // not a real log (for old IE versions) return null; } return console; } var _console = getConsole(); var _noop = _console ? null : function() {}; function getStackTrace(error) { var stacktraces = require('raptor-stacktraces'); return (stacktraces && stacktraces.trace) ? stacktraces.trace(error) : (error || ''); } function ConsoleAppender() { } ConsoleAppender.prototype = { /** * Log statements for all levels pass through this method. */ log: _console ? function(logEvent) { var logLevel = logEvent.logLevel; var logFn = _console[logLevel.methodName] || _console.log; if (!logFn) { return; } try { var args = logEvent.args.slice(0); var len = args.length; var error; for (var i=0; i