all files / src/meta/ logs.js

50% Statements 5/10
0% Branches 0/4
25% Functions 1/4
50% Lines 5/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                             
'use strict';
 
var path = require('path'),
	fs = require('fs'),
	winston = require('winston');
 
module.exports = function(Meta) {
 
	Meta.logs = {
		path: path.join('logs', path.sep, 'output.log')
	};
 
	Meta.logs.get = function(callback) {
		fs.readFile(this.path, {
			encoding: 'utf-8'
		}, function(err, logs) {
			if (err) {
				winston.error('[meta/logs] Could not retrieve logs: ' + err.message);
			}
 
			callback(undefined, logs || '');
		});
	};
 
	Meta.logs.clear = function(callback) {
		fs.truncate(this.path, 0, callback);
	};
};