How to use logmagic - 10 common examples

To help you get started, we’ve selected a few logmagic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github racker / dreadnot / lib / stack.js View on Github external
sinkName = sprintf('stack.%s', name),
      moduleName;

  if (config.stacks[name].hasOwnProperty('module_name')) {
    moduleName = config.stacks[name].module_name;
  }
  else {
    moduleName = name;
  }

  this.name = name;
  this.dreadnot = dreadnot;
  this.module = require(path.join(path.resolve(dreadnot.stackdir), moduleName));
  this.config = config;
  this.stackConfig = config.stacks[name];
  this.log = logmagic.local(logName);
  this.logRoot = path.join(config.data_root, 'logs', name);
  this.newestDeployments = {};
  this.repo = this.stackConfig.repo || name;
  this.current = null;
  this._cache = {};
  this._waiting = {};

  logmagic.registerSink(sinkName, function(moduleName, lvl, msg, obj) {
    var both = moduleName.split('.').slice(-2),
        logPath = ['regions', both[0], 'deployments', both[1], 'log'].join('.');

    // Fix serialization of Error objects
    if (obj.err && obj.err instanceof Error) {
      obj.err = {
        name: obj.err.name,
        message: obj.err.message,
github racker / node-rproxy / lib / util / keystone_client.js View on Github external
*
 *      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 querystring = require('querystring');

var async = require('async');

var log = require('logmagic').local('lib.util.keystone_client');

var sprintf = require('./sprintf').sprintf;
var request = require('./request');
var misc = require('./misc');
var errors = require('./errors');

var KEYSTONE_SUCCESS_STATUS_CODES = [200, 203];

/* We trust the token is valid for at least 60 seconds */
var TRUST_TOKEN_FOR = 60;



/**
 * Create an OpenStack Keystone Identity API client.
 *
github Kami / node-buildbot-github / lib / buildbot.js View on Github external
var http = require('http');
var https = require('https');
var querystring = require('querystring');

var sprintf = require('sprintf').sprintf;
var log = require('logmagic').local('buildbot-github.buildbot');

var utils = require('./utils');

function BuildBot(options) {
  this._options = options;

  this._host = options['host'];
  this._port = options['port'];
  this._secure = options['secure'];
  this._username = options['username'];
  this._password = options['password'];

  this._changeHookPath = options['change_hook_path'];
  this._builderName = options['builder_name'];

  // Prepare objects which are used when making requests
github racker / dreadnot / lib / web / middleware / logger.js View on Github external
*
 *  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.
 *
 */

var log = require('logmagic').local('web.middleware.logger');


module.exports = function() {
  return function logger(req, res, next) {
    req._startTime = new Date();

    // mount safety
    if (req._logging) {
      return next();
    }

    // flag as logging
    req._logging = true;

    // proxy end to output loggging
    var end = res.end;
github Kami / node-bittorrent-tracker / lib / http / endpoints / announce.js View on Github external
/**
 * Based on specs at: http://wiki.theory.org/BitTorrent_Tracker_Protocol
 */

var util = require('util');

var sprintf = require('sprintf').sprintf;
var async = require('async');

var httpConstants = require('http/constants');
var httpUtil = require('util/http');
var config = require('util/config');
var log = require('logmagic').local('bittorrent-tracker.lib.http.endpoints.announce');

var middlewareParamValidator = require('http/middleware/param-validator');
var middlewareMethodValidator = require('http/middleware/method-validator');
var db = require('services/index').ServiceHandler.getDb();

function getParamDict(clientIpAddress) {
  var paramDict = {
    'info_hash': { 'default_value': null, 'type': 'string' },
    'peer_id': { 'default_value': null, 'type': 'string' },
    'ip': { 'default_value': clientIpAddress, 'type': 'string' }, // @TODO: Verify IP address if provided by the client
    'port': { 'default_value': null, 'type': 'number' },
    'uploaded': { 'default_value': null, 'type': 'number' },
    'downloaded': { 'default_value': null, 'type': 'number' },
    'left': { 'default_value': null, 'type': 'number' },
    'event': { 'default_value': 'announce', 'type': 'string' }, // announce, started, completed or stopped
    'numwant': { 'default_value': config.getValue('default_numwant'), 'type': 'number' },
github cloudkick / whiskey / lib / common.js View on Github external
* 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 fs = require('fs');
var path = require('path');
var net = require('net');
var util = require('util');

var sprintf = require('sprintf').sprintf;
var async = require('async');
var gex = require('gex');
var underscore = require('underscore');
var log = require('logmagic').local('whiskey.common');

var requiredAs = require('required-as');
var rewire = require('rewire');

var assert = require('./assert');
var constants = require('./constants');
var testUtil = require('./util');
var coverage = require('./coverage');
var scopeleaks = require('./scopeleaks');

var isValidTestFunctionName = function(name) {
  return name.indexOf('test') === 0;
};


// foo.bar.test.* -> [ foo/bar/test.js, '*' ]
github cloudkick / whiskey / lib / process_runner / runner.js View on Github external
* See the License for the specific language governing permissions and
 * limitations under the License.
 */

var fs = require('fs');
var path = require('path');
var net = require('net');
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;

var sprintf = require('sprintf').sprintf;
var term = require('terminal');
var async = require('async');
var simplesets = require('simplesets');
var logmagic = require('logmagic');
var log = require('logmagic').local('whiskey.process_runner.runner');

var util = require('../util');

// Set up logging
function sink(modulename, level, message, obj) {
  term.puts(sprintf('[green]%s[/green]: %s', modulename, message));
}

logmagic.registerSink('process_runner', sink);

var VALID_WAIT_FOR_OPTIONS = {
  'none': {
    'required_options': new simplesets.Set([]),
  },

  'stdout': {
github pquerna / node-logmagic / t.js View on Github external
var logmagic = require('logmagic');
var log = logmagic.local('mylib.foo.bar');
console.log(log);
log.info("Hello!");
log.error("Accepts format strings too ${SOME_VAR}", {SOME_VAR: "myvalue"});
log.trace("testing trace v0");
logmagic.route("__root__", logmagic.TRACE1, "console");
log.trace("testing trace v1", {slug: 1});
console.log(log);
github racker / dreadnot / lib / stack.js View on Github external
self.dreadnot.emitter.on(epath, onLog);

          self.dreadnot.emit('deployments', {
            user: user,
            stack: self.name,
            stackName: self.name,
            region: region,
            environment: self.config.env,
            deployment: number,
            from_revision: summary.deployed_revision,
            to_revision: revision,
            github_href: self.getGitHubBaseUrl(),
            time: start
          });

          baton.log = logmagic.local(sprintf('deploy.stack.%s.%s.%s', self.name, region, number));

          tasks = target.map(function(taskName) {
            return function(callback) {
              var startTime, endTime;

              baton.log.infof('executing task ${task}', {
                task: taskName
              });

              startTime = misc.getUnixTimestamp();
              self.module[taskName](self, baton, args, function onEnd(err) {
                var args = arguments, logObj;
                endTime = misc.getUnixTimestamp();

                logObj = {
                  task: taskName,
github racker / service-registry / node_modules / rproxy / lib / proxy / server.js View on Github external
*  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 os = require('os');
var path = require('path');

var sprintf = require('sprintf').sprintf;
var Cluster = require('cluster2');
var httpProxy = require('http-proxy');
var async = require('async');
var log = require('logmagic').local('lib.server');
var misc = require('rackspace-shared-utils/lib/misc');
var generateTxnId = require('../util/config').generateTxnId;

var constants = require('./../constants');
var fsUtil = require('./../util/fs');
var ProxyError = require('./../util/errors').ProxyError;


/**
 * Reverse proxy server.
 *
 * @param {Object} options Options object.
 */
function ReverseProxyServer(options) {
  this._options = options;
  this._server = httpProxy.createServer(this.processRequest.bind(this));

logmagic

Dynamic and Configurable logging library for node.js

Apache-2.0
Latest version published 9 years ago

Package Health Score

39 / 100
Full package analysis

Popular logmagic functions