mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Instead of instructing users to do static calls in to Unleash, she should instead be allwed to specify the log provider as an option to Unleash. This commit introduces the "getLogger" option, a function responsible for creating a logger.
		
			
				
	
	
		
			26 lines
		
	
	
		
			667 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			667 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
 | 
						|
const Controller = require('./controller');
 | 
						|
 | 
						|
class HealthCheckController extends Controller {
 | 
						|
    constructor(config) {
 | 
						|
        super();
 | 
						|
        this.db = config.stores.db;
 | 
						|
        this.logger = config.getLogger('health-check.js');
 | 
						|
 | 
						|
        this.get('/', (req, res) => this.index(req, res));
 | 
						|
    }
 | 
						|
 | 
						|
    async index(req, res) {
 | 
						|
        try {
 | 
						|
            await this.db.select(1).from('features');
 | 
						|
            res.json({ health: 'GOOD' });
 | 
						|
        } catch (e) {
 | 
						|
            this.logger.error('Could not select from features, error was: ', e);
 | 
						|
            res.status(500).json({ health: 'BAD' });
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
module.exports = HealthCheckController;
 |