Transparently embed log code on method call / complete

I want to log the start and completion of every method call. I.e. to loggly.

I don’t want to have to explicitly write any logging code within the method itself. Is it possible to hook into the method call lifecycle and invoke my log code transparently?

I also want to achieve this, did you find a way of doing it?

The only thing I can think of is to hack Meteor.call on the server with an expanded version of itself

https://github.com/meteor/meteor/blob/devel/packages/ddp-server/livedata_server.js#L1597

var events = Npm.require("events");
var eventEmitter = new events.EventEmitter();

const callTemp = Meteor.call;

Meteor.call = function (name, ...args) {
  self = this;

  if (args.length && typeof args[args.length - 1] === "function") {
    // If it's a function, the last argument is the result callback, not
    // a parameter to the remote method.
    var callback = args.pop();
  }

    eventEmitter.emit('callAttempt',{
      userId : self.userId,
      method : name,
      args : args
    });

    let attempt = this.apply(name, args, callback);
    
    eventEmitter.emit('callResult',{
      userId : self.userId,
      method : name,
      args : args,
      result : attempt
    });
  
    return attempt;
};

Then somewhere else you can handle what you want to do with your emitted events such as logging them. I’m not currently using this code because hacking the core really isn’t recommended, but I’m at a loss of how else you could do it without literally copy-coding your emitters into every single method in your app.

Does anyone have a better way to do logging of method calls?