Auth0 Home Blog Docs

ERROR: Cannot find module 'auth0-common-logging'

function (user, context, callback) {
  var HttpWritableStream = require('auth0-common-logging').Streams.HttpWritableStream;
var httpWritableStream = new HttpWritableStream('<<sumo end point>>');

var data = '{"Trigger":"data" }';
httpWritableStream.write(data, function() {
  // Now the data has been written.
});
  // TODO: implement your rule
  callback(null, user, context);
}

when I run the above code, I am getting an error like “ERROR: Cannot find module ‘auth0-common-logging’”.
also, I had tried multiple forms such as of require(‘auth0/auth0-common-logging’)

I used as per below page,

https://github.com/auth0/auth0-common-logging

Hello @v-bnatarajan,

I looks like the auth0-common-logging package is available in via npm for use in your own code, but it is not yet available for use in rules. You can check which packages are available for use in rules at https://auth0-extensions.github.io/canirequire/, and you can request new packages be added at the link below:

1 Like

Hi @v-bnatarajan,

The ‘auth0-common-logging’ package is currently not available for use from within rules. You may use any of the logging packages at https://auth0-extensions.github.io/canirequire/#log . There’s one for sumologic: https://github.com/SumoLogic/js-sumo-logger which is currently available from within a rule. Please let me know if you have further questions.

thanks @Omar.A and @markd for the response.

i had implemented in another way ,

function (user, context, callback) {
 var stream  = require('stream');
  var request = require('request');
  var _       = require('lodash');
  var writable = new stream.Writable({
  write: function(chunk, encoding, next) {
  var entry = chunk.toString();
  var json = JSON.parse(entry);
  var self = this;
  request.post({
    url:  configuration.SUMO_URL,
    json: json
  }, _.noop).on('error', function (err) {
    self.emit('error', err);
  });
   return  next();
  } 
});
  
  var data = { 
 "email_template":"Validation Error occured",
 "user_data_id":user.user_id
};
  
    data.rule_name="sendlogs";
    data.email_template="Trigger email in sumo";
   const json = JSON.stringify(data);

  writable.write(json);
  
  
  callback(null, user, context);
}