Skip to content

Commit

Permalink
Merge pull request #2 from yahehe/logging
Browse files Browse the repository at this point in the history
Follow standard logging patterns and expect proper logger
  • Loading branch information
yahehe authored Jun 19, 2017
2 parents 04ba67a + 79d73b4 commit 65b1820
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/auth0V1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const cache = require('./cache');

// TODO: get from options
const REFRESH_TOKEN_CLIENT_ID = process.env.DEFAULT_TARGET_ID || 'QkxOvNz4fWRFT6vcq79ylcIuolFz2cwN';
let logger = console.log;
let logger = process.env.NODE_DEBUG && process.env.NODE_DEBUG.includes('cimpress-auth0-client-request-promise')
? console.log
: () => { };

const generateAuthV1TokenCacheKey = config =>
(config.clientId ? `${config.targetId}-${config.clientId}` : `${config.targetId}`);
Expand Down
4 changes: 3 additions & 1 deletion src/auth0V2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const request = require('request-promise');
const cache = require('./cache');
const auth0V1 = require('./auth0V1');

let logger = console.log;
let logger = process.env.NODE_DEBUG && process.env.NODE_DEBUG.includes('cimpress-auth0-client-request-promise')
? console.log
: () => { };

const generateAuthV2TokenCacheKey = (config, audience) => `${audience}-${config.clientId}`;

Expand Down
4 changes: 3 additions & 1 deletion src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const defaultCache = {

let credentialCache = defaultCache;
let keyGenFunc;
let logger;
let logger = process.env.NODE_DEBUG && process.env.NODE_DEBUG.includes('cimpress-auth0-client-request-promise')
? console.log
: () => { };

const parseCacheControlHeader = (headers) => {
if (headers) {
Expand Down
4 changes: 3 additions & 1 deletion src/passedInAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const _ = require('lodash');
const auth0V2 = require('./auth0V2');
const cache = require('./cache');

let logger = console.log;
let logger = process.env.NODE_DEBUG && process.env.NODE_DEBUG.includes('cimpress-auth0-client-request-promise')
? console.log
: () => { };

const makeRequest = (options, retryLoop) => {
const requestOptions = _.assign({}, options);
Expand Down

0 comments on commit 65b1820

Please sign in to comment.