Skip to content

Commit

Permalink
replace console.log
Browse files Browse the repository at this point in the history
replace console.log by debug statements
  • Loading branch information
ernie58 committed Mar 3, 2016
1 parent fdcf4f8 commit ab20121
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -10,6 +10,7 @@
"engines": { "node": ">= 0.8.0" },
"dependencies":{
"hogan.js":"",
"readdir":"*"
"readdir":"*",
"debug": "*"
}
}
11 changes: 6 additions & 5 deletions src/template-engine.js
Expand Up @@ -3,6 +3,7 @@ var Hogan = require('hogan.js');
var ReadDir = require('readdir');
var Path = require('path');
var FS = require('fs');
var debug = require('debug')('hogan');

function TemplateEngine(settings) {
if (settings) {
Expand Down Expand Up @@ -66,7 +67,7 @@ TemplateEngine._storeTemplate = function(templatePath) {
var templateName = Path.basename(templatePath, Path.extname(templatePath));
TemplateEngine.__templates[templateName] = Hogan.compile(FS.readFileSync(templatePath, 'utf-8'));

console.log('Stored template', templateName);
debug('Stored template %s', templateName);
};

/**
Expand All @@ -89,7 +90,7 @@ TemplateEngine._getTemplates = function(templatesPath) {
* @param {String} templatesPath
*/
TemplateEngine._refreshWatches = function(templatesPath) {
console.log('Refreshing watched directories');
debug('Refreshing watched directories');

// Remove any existing watches
TemplateEngine._watches.splice(0).forEach(function(watch) {
Expand All @@ -98,7 +99,7 @@ TemplateEngine._refreshWatches = function(templatesPath) {

ReadDir.readSync(templatesPath, ['**/'], ReadDir.ABSOLUTE_PATHS + ReadDir.INCLUDE_DIRECTORIES)
.forEach(function (path) {
console.log(' [WATCH] ', path);
debug(' [WATCH] %s', path);
TemplateEngine._watches.push(
FS.watch(path, {persistent:false}, TemplateEngine._refreshTemplates.bind(TemplateEngine, templatesPath))
);
Expand All @@ -112,14 +113,14 @@ TemplateEngine._refreshWatches = function(templatesPath) {
* @param {String} templatesPath
*/
TemplateEngine._refreshTemplates = function(templatesPath) {
console.log('Refreshing templates for', templatesPath);
debug('Refreshing templates for %s', templatesPath);

TemplateEngine._refreshWatches(templatesPath);

TemplateEngine.__templates = {};
ReadDir.readSync(templatesPath, TemplateEngine.__settings.filter, ReadDir.ABSOLUTE_PATHS)
.forEach(TemplateEngine._storeTemplate, TemplateEngine);
console.log('Refreshing templates complete');
debug('Refreshing templates complete');
};

module.exports = TemplateEngine;

0 comments on commit ab20121

Please sign in to comment.