Skip to content

Commit

Permalink
Test and cleaned up the logging library
Browse files Browse the repository at this point in the history
  • Loading branch information
billxinli committed May 6, 2016
1 parent 6217611 commit e106aac
Show file tree
Hide file tree
Showing 2 changed files with 409 additions and 317 deletions.
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ class JsonApi {
logger: true
}

if (arguments.length === 2 || (arguments.length === 1 && _.isString(arguments[0]))) {
let deprecatedConstructos = (args) => {
return (args.length === 2 || (args.length === 1 && _.isString(args[0])))
}

if (deprecatedConstructos(arguments)) {
defaults.apiUrl = arguments[0]
if (arguments.length === 2) {
defaults.middleware = arguments[1]
}
console.error('Constructor (apiUrl, middleware) has been deprecated, initialize Devour with an object.')
}

options = _.assign(defaults, options)
Expand All @@ -69,9 +72,12 @@ class JsonApi {
this.serialize = serialize
this.builderStack = []
this.logger = Minilog('devour')

options.logger ? Minilog.enable() : MiniLog.disable()

if (deprecatedConstructos(arguments)) {
this.logger.warn('Constructor (apiUrl, middleware) has been deprecated, initialize Devour with an object.')
}

}

enableLogging(enabled = true){
Expand Down
Loading

0 comments on commit e106aac

Please sign in to comment.