You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					23 lines
				
				496 B
			
		
		
			
		
	
	
					23 lines
				
				496 B
			| 
								 
											4 years ago
										 
									 | 
							
								let levels = ['error', 'warn', 'log', 'info'];
							 | 
						||
| 
								 | 
							
								let level = 'warn';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function debug(method, ...args) {
							 | 
						||
| 
								 | 
							
								  if (levels.indexOf(method) <= levels.indexOf(level)) {
							 | 
						||
| 
								 | 
							
								    console[method](...args);  // eslint-disable-line no-console
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function namespace(ns) {
							 | 
						||
| 
								 | 
							
								  return levels.reduce(function(logger, method) {
							 | 
						||
| 
								 | 
							
								    logger[method] = debug.bind(console, method, ns);
							 | 
						||
| 
								 | 
							
								    return logger;
							 | 
						||
| 
								 | 
							
								  }, {});
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								debug.level = namespace.level = function(newLevel) {
							 | 
						||
| 
								 | 
							
								  level = newLevel;
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								export default namespace;
							 |