// TODO: To decide and adopt to some logging utility like winston
var util = require('util');

module.exports = {
  info: function(message,context) {
    if(context) {
      console.log(message, util.format('%j', context));
    }
    else {
      console.log(message);
    }
    
  },
  error: function(message, error) {
    console.error(message, util.format('%j', error));
  }
};

@@ -146,207 +146,460 @@
 t) %7B
+%09
 %0A    
-if(context) %7B%0A      console.log(message, util.format('%25j', context));%0A    %7D%0A    else %7B%0A      console.log(message);%0A    %7D%0A    %0A  %7D,%0A  error: function(message, error) %7B%0A    console.error(message, 
+var logItem = %7B%0A      timestamp: new Date(),%0A      source: 'autoscaler:apiserver',%0A      text: message,%0A      log_level: 'info',%0A      data: context === null ? %7B%7D : context%0A    %7D;%0A    console.log (util.format('%25j', logItem)); %0A  %7D,%0A  error: function(message, error) %7B%0A    var logItem = %7B%0A      timestamp: new Date(),%0A      source: 'autoscaler:apiserver',%0A      text: message,%0A      log_level: 'error',%0A      data: error%0A    %7D;%0A    console.error (
 util
@@ -612,21 +612,23 @@
 t('%25j', 
-error
+logItem
 ));%0A  %7D%0A

Prepare log output as parseable JSON data