kolyasya:auto-logger

v1.0.0-beta.0Published last month

kolyasya:auto-logger — Log Meteor DDP events automatically

Features:

  • Print all DDP messages (except ping/pong and filtered by ddpMessageFilter to server console)
  • Print all DDP messages into ddp-log.json file
  • Print summary of called subsciptions and methods to server console by interval

Installation:

meteor add kolyasya:auto-logger

Package settings:

1{
2  // ...regular Meteor settings.json file...
3
4  packages: {
5
6    // ...other packages settings...,
7
8    "kolyasya:auto-logger": {
9
10      // Logs for debugging purposes, not needed in normal circumstances
11      "enablePackageDebugLogs": false,
12
13      // Main logging to be printed in console
14      "enableDDPAutoLogger": true,
15
16      // Log all DDP events into file in root Meteor directory
17      "enableDDPFileLogger": false,
18      // In case if you need a non-standard path
19      "ddpFileLoggerPath": '../../../../..'
20
21      // Calculates sum of sub and methods calls
22      "enableDDPTallyLogger": true,
23      // Interval for calculation
24      "DDPTallyLoggerSeconds": 60,
25
26      // Cache is used only for current user now, time in ms
27      "customCacheTime": 300000
28    }
29  }
30}

Usage example:

1import AutoLogger from "meteor/kolyasya:auto-logger";
2
3new AutoLogger({
4  // Doing it like this to preserve 'this'
5  eventsLogger: (message) => {
6    console.log("This is events log message:", message);
7  },
8  tallyLogger: (message) => {
9    console.log("This is tally log message:", message);
10  },
11
12  ddpMessageFilter: ({ messageJSON }) => {
13    // Exclude loggly messages
14    return messageJSON?.method?.includes("loggly.") ? false : true;
15  },
16});