Logging from Extensions

Good day,

I am working on spinning up a new installation of GenieACS 1.2 due to its automation abilities. At this time, I’m working on an extension script and I am not being successful in getting it to log debugging information anywhere.

GenieACS is installed on a Ubuntu 19 server utilizing the recommended installation method from the GenieACS docs. Therefore, my extension scripts are located in /opt/genieacs/ext. In order to make any libraries load, I created the directory /opt/genieacs/lib and placed a copy of all the libraries in this location.

The first problem is I am unable to load the logger with require("…/lib/logger"); I must specify the full “/opt/genieacs/lib/logger” path. Even then, occasionally, the script will error out with the message:
Channel has faulted; channel=“test” retries=0 faultCode=“ext.Error” faultMessage=“Cannot find module ‘/opt/genieacs/lib/logger’”

I can clear the fault and re-trigger the script and it will work fine the next time. Should I not be using the GenieACS logger library and use a NodeJS logger library instead?

2nd, when the logger does load and the script runs, there is no log output anywhere. I’m sure this is a noob question, but how do I make the extension log to a file so I can debug and know what is happening?

-Eric

I use v1.1 still and use console.log in my extension scripts. Try that and see how that works for you.

Hello,

I was able to get this working in v1.2 by using console.log and using journalctl in follow mode (-f) against the genieacs-cwmp daemon (-c genieacs-cwmp) to view the extension messages. Thanks for the poke in the proper direction.

Eric

Hi Eric,
I too am having the same issue of not seeing the log message from the extensions.
I am using v1.2
I am running the extension script described in the documentation: http://docs.genieacs.com/en/latest/extensions.html
and I’ve added one “console.log” to test the logging from the extension.


“use strict”;

const http = require(“http”);

let cache = null;
let cacheExpire = 0;

function latlong(args, callback) {
if (Date.now() < cacheExpire)
return callback(null, cache);

http.get(“http://api.open-notify.org/iss-now.json”, (res) => {
if (res.statusCode !== 200)
return callback(new Error(Request failed (status code: ${res.statusCode})));

let rawData = "";
res.on("data", (chunk) => rawData += chunk);

res.on("end", () => {
  console.log('received data from OSS');              <--  see this
  let pos = JSON.parse(rawData)["iss_position"];
  cache = [+pos["latitude"], +pos["longitude"]];
  cacheExpire = Date.now() + 10000;
  callback(null, cache);
});

}).on(“error”, (err) => {
callback(err);
});
}

exports.latlong = latlong;

I know that this script runs successfully because I see the returned values in the provision script that 's calling the extension.

I tried running this to view the messages from the extension:
journalctl -u genieacs-cwmp.service -f

However, I do not see the log message from the extension anywhere.

thanks !