Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #313 from Financial-Times/logging-flags
Browse files Browse the repository at this point in the history
Logging flags
  • Loading branch information
triblondon committed Oct 2, 2015
2 parents 44852bc + 2e5270f commit 683ec0c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Runs:
- buildFolder: `String` Path to directory where the built file will be created. If set to `'disabled'`, files won't be saved. (Default: './build/')
- env: `String` It can be either 'production' or 'development'. If it's 'production', it will compile the Sass file with the 'compressed' style option and will also run [clean-css](https://github.com/jakubpawlowicz/clean-css). (Default: 'development')
- cleanCss: `Object` Config object to pass to [clean-css](https://github.com/jakubpawlowicz/clean-css/blob/master/README.md#how-to-use-clean-css-programmatically). (Default: `{advanced: false}`)
- sassIncludePaths: `Array` List of paths to search for Sass imports. (Default: '[]')

### `demo`

Expand Down
45 changes: 24 additions & 21 deletions lib/helpers/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@

require('colors');

let debugLog = function() {};
const noOp = () => {};

if (process.env.OBT_DEBUG === 'true') {
debugLog = function(text) {
console.log(String(text).grey);
};
}
const loggingEnabled = process.env.OBT_LOG_LEVEL !== 'none';
const debugLoggingEnabled = process.env.OBT_LOG_LEVEL === 'debug';

module.exports = {

primary: function(text) {
console.log(String(text).bold);
},
const primary = (text) => {
console.log(String(text).bold);
};

primaryError: function(text) {
console.log(String(text).bold.red);
},
const primaryError = (text) => {
console.log(String(text).bold.red);
};

secondary: function(text) {
console.log(String(text).grey);
},
const secondary = (text) => {
console.log(String(text).grey);
};

debug: debugLog,
const secondaryError = (text) => {
console.log(String(text).red);
};

secondaryError: function(text) {
console.log(String(text).red);
}
const debug = (text) => {
console.log(String(text).grey);
};

module.exports = {
primary: (loggingEnabled) ? primary : noOp,
primaryError: (loggingEnabled) ? primaryError : noOp,
secondary: (loggingEnabled) ? secondary : noOp,
secondaryError: (loggingEnabled) ? secondaryError : noOp,
debug: (debugLoggingEnabled) ? debug : noOp
};

0 comments on commit 683ec0c

Please sign in to comment.