 		warn: 2
 		info: 3
 		debug: 4
+		trace: 5
 		
 	@setLevel: (level) ->
-		levelName = "debug"
-		levelValue = 4
+		levelName = null
+		levelValue = null
 		for name,val of Logger.levels
 			if level == name or level == val
 				levelName = name
 				levelValue = val
 				break;
-			
-		log = new this {prefix: 'basic-logger'}
-		log.info "Setting log level to '"+levelName+"'"
-		exports.level = levelValue		
+		
+		log = new this {prefix: 'basic-logger'}	
+		if levelName? and levelValue?
+			log.info "Setting log level to '"+levelName+"'"
+			exports.level = levelValue
+		else
+			log.warn "Can't set log level to '"+level+"'. This level does not exist."		
 
 	constructor: (config={}) ->
-		@config = _.defaults config,Logger.defaultConfig
+		@config = _.defaults config,exports.defaultConfig
 
 	padZeros: (num,digits) ->
 		num = String num

			date = new Date
			timestamp = date.getFullYear()+"-"+@padZeros((date.getMonth()+1),2)+"-"+@padZeros(date.getDate(),2)+" "+@padZeros(date.getHours(),2)+":"+@padZeros(date.getMinutes(),2)+":"+@padZeros(date.getSeconds(),2)
			timestamp += "."+@padZeros(date.getMilliseconds(),3) if @config.showMillis
			msg = JSON.stringify msg if @config.stringifyJSON
			output = ''
			output += '['+timestamp+']' if @config.showTimestamp
			output += ' '+@config.prefix if @config.prefix != ""

# default level = debug
exports.level = 4

# default options
exports.defaultConfig = 
	showMillis: false
	showTimestamp: true
	printObjFunc: JSON.stringify
	prefix: ""

module.exports = class Logger
		
	@levels =
		error: 1
