Skip to content

Commit

Permalink
feat: add debug statements instead of log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Feb 12, 2017
1 parent 1abe3e0 commit e425040
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion dadi/lib/api/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var _ = require('underscore')
var debug = require('debug')('api')
var fs = require('fs')
var http = require('http')
var https = require('https')
Expand Down Expand Up @@ -108,7 +109,7 @@ Api.prototype.use = function (path, handler) {
regex: regex
})

log.warn({module: 'api'}, 'Loaded ' + path)
debug('loaded %s', path)

this.paths.sort((a, b) => {
return b.order - a.order
Expand Down
3 changes: 1 addition & 2 deletions dadi/lib/cache/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @module Cache
*/
var _ = require('underscore')
var crypto = require('crypto')
var path = require('path')
var url = require('url')
var _ = require('underscore')

var config = require(path.join(__dirname, '/../../../config.js'))
var log = require('@dadi/logger')
Expand All @@ -18,7 +18,6 @@ var cache = new DadiCache(config.get('caching'))
* @param {Server} server - the main server instance
*/
var Cache = function (server) {
log.info({module: 'cache'}, 'Cache logging started.')
this.server = server
this.enabled = config.get('caching.directory.enabled') || config.get('caching.redis.enabled')
this.encoding = 'utf8'
Expand Down
5 changes: 2 additions & 3 deletions dadi/lib/controller/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ REWRITE INFO:
https://github.com/tinganho/connect-modrewrite
*/
var _ = require('underscore')
var debug = require('debug')('router')
var es = require('event-stream')
var fs = require('fs')
var path = require('path')
Expand All @@ -22,8 +23,6 @@ var RouteValidator = require(path.join(__dirname, '../datasource/route-validator
var rewriteFunction = null

var Router = function (server, options) {
log.info({module: 'router'}, 'Router logging started.')

this.data = {}
this.params = {}
this.constraints = {}
Expand Down Expand Up @@ -149,7 +148,7 @@ Router.prototype.constrain = function (route, constraint) {
// add constraint from /{routesPath}/constraints.js if it exists
if (this.handlers[constraint]) {
this.constraints[route] = this.handlers[constraint]
log.info({module: 'router'}, "Added route constraint function '%s' for '%s'", constraint, route)
debug('added route constraint function "%s" for %s', constraint, route)
} else {
var error = "Route constraint '" + constraint + "' not found. Is it defined in '" + this.options.routesPath + "/constraints.js'?"
var err = new Error(error)
Expand Down
2 changes: 2 additions & 0 deletions dadi/lib/dust/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const debug = require('debug')('dust')
const dust = require('dustjs-linkedin')
const fs = require('fs')
const mkdirp = require('mkdirp')
Expand Down Expand Up @@ -63,6 +64,7 @@ Dust.prototype.load = function (source, templateName) {
}

Dust.prototype.loadDirectory = function (directory, prefix, recursive) {
debug('loadDirectory %o %s %s', directory, prefix, recursive)
prefix = prefix || ''

return new Promise((resolve, reject) => {
Expand Down
5 changes: 3 additions & 2 deletions dadi/lib/middleware/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/**
* @module Middleware
*/
var path = require('path')
var debug = require('debug')('middleware')
var log = require('@dadi/logger')
var path = require('path')

var Middleware = function (name, options) {
log.info({module: 'middleware'}, 'Middleware logging started (' + name + ').')
debug('loaded %s', name)

this.name = name
this.options = options || {}
Expand Down
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var chokidar = require('chokidar')
var cluster = require('cluster')
var config = require('./config')
var debug = require('debug')('cluster')
var fs = require('fs')
var path = require('path')

Expand Down Expand Up @@ -66,11 +67,11 @@ if (config.get('cluster')) {
}
} else {
// Single thread start
log.info('Starting DADI Web in single thread mode.')
debug('starting DADI Web in single thread mode.')

app = require(path.join(__dirname, '/index.js'))
app.start(function () {
log.info('Process ' + process.pid + ' is listening for incoming requests')
debug('process ' + process.pid + ' is listening for incoming requests')
})
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
"colors": "latest",
"common-dustjs-helpers": "^0.1.0",
"compression": "^1.6.0",
"connect-mongo": "1.0.1",
"connect-mongo": "latest",
"connect-redis": "3.0.2",
"console-stamp": "^0.2.2",
"convict": "2.0.0",
"debug": "^2.6.1",
"dustjs-helpers": "^1.7.3",
"dustjs-linkedin": "^2.7.2",
"event-stream": "^3.3.1",
Expand All @@ -40,7 +41,7 @@
"marked": "^0.3.5",
"mkdirp": "^0.5.1",
"moment": "^2.10.6",
"mongodb": "1.4.7",
"mongodb": "2.2.x",
"node-uuid": "latest",
"path-to-regexp": "^1.2.1",
"perfy": "^1.1.0",
Expand Down

0 comments on commit e425040

Please sign in to comment.