Skip to content

Commit

Permalink
Merge pull request #423 from telefonicaid/task/log_config_at_startup
Browse files Browse the repository at this point in the history
add more logs
  • Loading branch information
fgalan authored Feb 6, 2020
2 parents 2c43b3c + dbdaf4b commit 1882afb
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix: improving logs system, adding more traces and changes to avoid too verbose messages at INFO level
2 changes: 2 additions & 0 deletions lib/models/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function conditionalExec(task, lastTime, callbackW) {
}
}
function slaveExec(task, alreadyExecuted, callback) {
logger.debug('slaveExec alreadyExecuted=%s task %j', alreadyExecuted, task);
if (!alreadyExecuted) {
async.waterfall([executionsStore.LastTime.bind(null, task), conditionalExec.bind(null, task)], function(err) {
callback(err);
Expand Down Expand Up @@ -245,6 +246,7 @@ function DoAction(event, callback) {
queue = getInProcessArray(service, subservice, ruleName, id, type);
for (i = 0; i < actions.length; i++) {
actions[i].index = i;
logger.debug('inserting in queue action %s', actions[i]);
queue.push({
action: actions[i],
event: event,
Expand Down
2 changes: 1 addition & 1 deletion lib/perseo.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function start(callbackStart) {

logger.info(context, 'starting perseo');
logger.setLevel(config.logLevel);

logger.debug(context, 'Using config:\n\n%s\n', JSON.stringify(config, null, 4));
logger.getContext = function getDomainContext() {
if (process.domain) {
return process.domain.context;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/actionsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function PostAction(req, resp) {
firedEvent = req.body || {};
firedEvent.subservice = req.subservice;
firedEvent.service = req.service;

logger.debug({}, 'Post action');
metrics.IncMetrics(req.service, req.subservice, metrics.firedRules);

if (correlator) {
Expand Down
2 changes: 2 additions & 0 deletions lib/routes/checkController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

var config = require('../../config'),
myutils = require('../myutils'),
logger = require('logops'),
errorNotAMaster;

/*jshint quotmark: double */
Expand All @@ -32,6 +33,7 @@ errorNotAMaster = new Error("I'm not a master");
errorNotAMaster.httpCode = 400;

function Check(req, resp) {
logger.debug({}, 'Check');
if (config.isMaster) {
myutils.respondWOMetrics(resp, null, 'OK');
} else {
Expand Down
3 changes: 3 additions & 0 deletions lib/routes/metricsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@

var config = require('../../config'),
myutils = require('../myutils'),
logger = require('logops'),
metrics = require('../models/metrics');

function getMetrics(req, resp) {
var reset = req.query.reset === 'true';
logger.debug({}, 'Get metrics');
myutils.respondWOMetrics(resp, null, metrics.GetDecorated(reset), /* withCount */ false, /* raw */ true);
}

function deleteMetrics(req, resp) {
logger.debug({}, 'Delete metrics');
metrics.DeleteMetrics();
resp.status(200).end(); // Don't need myutils, body is empty
}
Expand Down
3 changes: 2 additions & 1 deletion lib/routes/rulesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function GetAllRules(req, resp) {
var limit = req.query && req.query.limit ? req.query.limit : 1000;
var offset = req.query && req.query.offset ? req.query.offset : 0;
var count = req.query && req.query.options ? req.query.options === 'count' : true;
logger.debug({}, 'getting all rules');
rules.FindAll(req.service, req.subservice, function(err, data) {
if (util.isArray(data)) {
resp.set(constants.TOTAL_COUNT_HEADER, data.length);
Expand All @@ -48,7 +49,7 @@ function GetRules(req, resp) {
subservice: req.subservice,
service: req.service
};
logger.info({}, 'getting rule %j', rule);
logger.debug({}, 'getting rule %j', rule);
rules.Find(rule, function(err, data) {
myutils.respond(resp, err, data);
});
Expand Down
3 changes: 2 additions & 1 deletion lib/routes/visualRulesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function GetAllVR(req, resp) {
var limit = req.query.limit ? req.query.limit : 1000;
var offset = req.query.offset ? req.query.offset : 0;
var count = req.query && req.query.options ? req.query.options === 'count' : true;
logger.debug({}, 'getting all Vrules ');
visualRules.FindAll(req.service, req.subservice, function(err, data) {
if (!err && util.isArray(data)) {
data = data.map(function(e) {
Expand All @@ -53,7 +54,7 @@ function GetVR(req, resp) {
subservice: req.subservice,
service: req.service
};
logger.info({}, 'getting Vrule ' + rule);
logger.debug({}, 'getting Vrule ' + rule);
visualRules.Find(rule, function(err, data) {
if (!err && data) {
delete data.subservice;
Expand Down

0 comments on commit 1882afb

Please sign in to comment.