(Super-simple) Logger

@param context {String} Logger context
772367
function Logger (context) {
    var loggerObj, i;

    if (!context || context.length === 0) {
        throw new Error("Invalid 'context' for Logger: " + context);
    }

    loggerObj = {
        debug   : function(scope, message) {
            console.debug(context + separator +
                scope +
                (message && message.length > 0 ? separator + message : "")
            );
        },
        info    : function(scope, message) {
            console.info(context + separator +
                scope +
                (message && message.length > 0 ? separator + message : "")
            );
        },
        warn    : function(scope, message) {
            console.warn(context + separator +
                scope +
                (message && message.length > 0 ? separator + message : "")
            );
        },
        error   : function(scope, message) {
            console.error(context + separator +
                scope +
                (message && message.length > 0 ? separator + message : "")
            );
        }
    };


    return loggerObj;
}
165093
function logger (message, warn) {
  if (appOptions.silent) {
    return
  }
  if (warn) {
    console.warn(message)
    return
  }

  console.log(message)
}
1320346
public static void registerLogListener(@NonNull final Context context, @NonNull final DfuLogListener listener) {
		if (mLogBroadcastReceiver == null) {
			mLogBroadcastReceiver = new LogBroadcastReceiver();

			final IntentFilter filter = new IntentFilter();
			filter.addAction(DfuBaseService.BROADCAST_LOG);
			LocalBroadcastManager.getInstance(context).registerReceiver(mLogBroadcastReceiver, filter);
		}
		mLogBroadcastReceiver.setLogListener(listener);
	}
479522
function log(msg) {
        if (msg === void 0) { msg = ""; }
        return action(function (p) { console.log(msg); }).setType("log");
    }
1063761
function (msg) {

            if (!isLog()) {
                return undefined;
            }

            if (msg) {
                console.log(_utils.now() + " " + msg);
                this.log2file(msg);
            }
        }
800655
function log(...messages) {
  console.log(...messages);
  const p = document.createElement('p');
  p.innerText = messages.join(' ');
  logElement.appendChild(p);
}
1233431
function Logger_addHook(callback) {
            if (!Type.isFunction(callback)) {
                throw new error.Exception('Logger hook must be function');
            }
            this.hooks.push(callback);
        }
785462
public static void log(Logger logger, ILoggingEvent event)
    {
        ((ch.qos.logback.classic.Logger) logger).callAppenders(event);
    }
573034
function logHeaders(logger, headers) {
	return _.each(_.keys(headers), function (key) {
		logger.info(key + ': ' + headers[key]);
	});
}
353388
function log() {
	var msg = util.format.apply(null, Array.prototype.slice.call(arguments, 0));
	write(msg);
}
543939
@Override
	public Module start(Module.Context context) {
		// FIXME: logger is a hack!
		final Logger logger = new Logger.Default(System.err);
		// List of commands to use
		context.register(Build.Platform.class, WHILEY_PLATFORM);
		// List of content types
		context.register(Content.Type.class, WhileyFile.ContentType);
		context.register(Content.Type.class, WyilFile.ContentType);
		// Done
		return new Module() {
			// what goes here?
		};
	}
566559
function log(message) {
  if (message instanceof Error) {
    console.log(message.stack);
  }

  if (CONFIG.debug) {
    if (typeof message === "object") {
      console.log(JSON.stringify(message, null, 2));
    } else {
      console.log(message);
    }
  }
}
1289813
public void setLogger(Logger logger) {

		System.out.println("LOGGER set");
//		if(logger instanceof SimpleFileLogger) {
			this.logger = logger;
			System.out.println("appender added");
			this.logger.addAppender(this);
//		}
	}
1224202
function logger() {
  if (hasGulplog()) {
    // specifically deferring loading here to keep from registering it globally
    var gulplog = require('gulplog');
    gulplog.info.apply(gulplog, arguments);
  } else {
    // specifically defering loading because it might not be used
    var fancylog = require('fancy-log');
    fancylog.apply(null, arguments);
  }
}
459888
function Logger() {
  /**
   * Write a simple log
   * @param {String|Object} message Message of body
   * @param {...*} [params] format the message body
   */
  this.log = function (message, params) {
    if (this.level() > 1) return;
    if (arguments.length > 1) message = String.prototype.format.apply(message, Array.prototype.slice.call(arguments, 1));
    message = this._prepareMessage('LOG', message);
    console.log(message);
    this._logToFile(message);
  };

  /**
   * Write a warning log
   * @param {String|Object} message Message of body
   * @param {...*} [params] format the message body
   */
  this.warn = function (message, params) {
    if (this.level() > 2) return;
    if (arguments.length > 1) message = String.prototype.format.apply(message, Array.prototype.slice.call(arguments, 1));
    message = this._prepareMessage('WARNING', message);
    console.warn(message);
    this._logToFile(message);
  };

  /**
   * Write a debug log
   * @param {String|Object} message Message of body
   * @param {...*} [params] format the message body
   */
  this.debug = function (message, params) {
    if (this.level() > 0) return;
    if (arguments.length > 1) message = String.prototype.format.apply(message, Array.prototype.slice.call(arguments, 1));
    message = this._prepareMessage('DEBUG', message);
    console.log(message);
    this._logToFile(message);
  };


  /**
   * Write an error message
   * @param {String|Object} message Message of body
   * @param {...*} [params] format the message body
   */
  this.error = function (message, params) {
    if (this.level() > 3) return;
    if (arguments.length > 1) message = String.prototype.format.apply(message, Array.prototype.slice.call(arguments, 1));
    message = this._prepareMessage('ERROR', message);
    console.error(message);
    this._logToFile(message);
  };


  /**
   * Prepares message
   * @param type What kind of message will be prepared
   * @param message What is the message
   * @returns {String}
   * @private
   */
  this._prepareMessage = function (type, message) {
    var simple = {
      type: this.colorType(type),
      message: typeof message == 'string' ? message : os.EOL + "{0 j 4}".format(message),
      var: defaults
    };
    switch (this.get('type')) {
      case 'simple':
        return this.get('simple').format(simple);
      case 'withFile':
        return this.get('withFile').format(Object.assign(simple, this._getActiveFunction()));
      default:
        var now = new Date();
        var date = this.get('dateFormat').format({
          year: now.getFullYear(),
          month: now.getMonth() + 1,
          day: now.getDate()
        });
        var time = this.get('timeFormat').format({
          hour: now.getHours(),
          minute: now.getMinutes(),
          second: now.getSeconds()
        });
        return (this.get(this.get('type')) || "").format(Object.assign(simple, {
          date: date,
          time: time
        }, this._getActiveFunction()));
    }
  };

  /**
   * Logs to file
   * @param message
   * @private
   */
  this._logToFile = function (message) {
    var now = new Date();
    var date = this.get('fileDateFormat').format({
      year: now.getFullYear(),
      month: now.getMonth() + 1,
      day: now.getDate()
    });
    var location = path.resolve(process.cwd(), this.get('dir'), this.get('fileFormat').format({date: date}));
    fs.appendFile(location, (message + os.EOL).replace(/\x1B\[\d+m/g, ''), function() {});
  };


  /**
   * Detect recording level
   * @returns {number}
   */
  this.level = function () {
    switch (this.get('level')) {
      case 'DEBUG':
        return 0;
      case 'LOG':
        return 1;
      case 'WARN':
        return 2;
      case 'ERROR':
        return 3;
      default:
        return 0;
    }
  };

  /**
   * Colored type
   * @returns {String}
   */
  this.colorType = function (type) {
    switch (type) {
      case 'DEBUG':
        return type.yellow;
      case 'LOG':
        return type.magenta;
      case 'WARN':
        return type.cyan;
      case 'ERROR':
        return type.red;
      default:
        return type;
    }
  };


  /**
   * Changes a default setting
   * @param {String} setting
   * @param {*} value
   * @return {String}
   */
  this.set = function (setting, value) {
    return defaults[setting] = value
  };


  /**
   * Gets a default setting
   * @param {String} setting
   * @return {String}
   */
  this.get = function (setting) {
    return defaults[setting]
  };


  /**
   * Finds file name that executing
   * @param {Number} [at] Stack position
   * @returns {{file: String, line: String}}
   * @private
   */
  this._getActiveFunction = function (at) {
    var temp = {};
    var stackTraceLimit = Error.stackTraceLimit;
    var prepareStackTrace = Error.prepareStackTrace;
    Error.stackTraceLimit = Infinity;

    Error.prepareStackTrace = function (dummyObject, v8StackTrace) {
      return v8StackTrace
    };
    Error.captureStackTrace(temp);

    var stack = temp.stack[at || 3];
    Error.prepareStackTrace = prepareStackTrace;
    Error.stackTraceLimit = stackTraceLimit;

    var file = stack["getEvalOrigin"]().split(/\\|\//).pop().blue;
    var line = stack["getLineNumber"]().toString().magenta;
    return {file: file, line: line};
  };

  /**
   * Check's logging directory's existence, if not then creates
   */
  this.checkDirectory = function () {
    var location = (path.resolve(process.cwd(), this.get('dir')));
    var dirs = location.split(path.sep), root = "";

    while (dirs.length > 0) {
      var dir = dirs.shift();
      if (dir === "") root = path.sep;
      if (!fs.existsSync(root + dir)) fs.mkdirSync(root + dir);
      root += dir + path.sep;
    }
  };

  this.checkDirectory();
}
211734
public void setLogger(String logger)
    {
        if(logger != null && logger.trim().length() > 0)
            this.logger = LoggerFactory.getLogger(logger);
    }
609141
function Logger (options) {
  if (!(this instanceof Logger)) return new Logger(options);

  options = options || {};

  debug('new logger v%s', pkg.version);

  var router = Router();
  router.on(function (sock, args, cb) {
    debug('logger args.length %s', arguments.length);
    try {
      // "this" is the "socket"
      logger.stream().write(logger.format(sock, args) + "\n");
      cb();
    }
    catch (e) {
      debug('caught an error %s', e);
      console.trace(e);
      cb(e);
    }
  });

  function logger (sock, cb) {
    debug('logger sock', sock, cb.toString());
    router(sock, cb);
  }

  logger.__proto__ = Logger.prototype;

  if (options.stream) {
    logger.stream(options.stream);
  }

  if (options.format) {
    logger.format(options.format);
  }

  return logger;
}