npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dm-logger

v1.0.12

Published

1. npm run build 1. cd demo 1. node logger-demo.js 1. npx ts-node -P tsconfig.demo.json index.ts

Downloads

162

Readme

Steps to Run

  1. npm run build
  2. cd demo
  3. node logger-demo.js
  4. npx ts-node -P tsconfig.demo.json index.ts

How to integrate this logger ?

  1. Add an .npmrc file
  2. Add this package from Azure Feeds to package.json
  3. Install Dependencies - npm i
  4. Create a logger initialization file (standard name - addLogConfig.js) with the following code snippet:
        const { logConfig: LogConfig } = require('@privatelib/logger');
    
        module.exports = (serviceConfigurations) => {
        const logConfig = new LogConfig();
    
        if (!serviceConfigurations) {
            return logConfig;
        }
        logConfig.debug = serviceConfigurations.debug;
        logConfig.logFileRetention = serviceConfigurations.logFileRetention;
        logConfig.datePattern = serviceConfigurations.datePattern;
        logConfig.logFolder = process.env.SERVICE_LOGS_PATH || serviceConfigurations.logFolder;
        logConfig.env = serviceConfigurations.env;
        logConfig.hostname = serviceConfigurations.hostname;
        logConfig.ipaddress = serviceConfigurations.ipaddress;
        logConfig.servicename = serviceConfigurations.servicename;
    
        return logConfig;
        };
    
  5. Add the following code to the starting point of the application. Make sure to add this before the other modules are getting loaded in the application.
        const loggerModule = require('@privatelib/logger');
        const addLogConfig = require('../addLogConfig');
    
        const logConfig = addLogConfig(configJson.logOptions);
        const loggerObject = new loggerModule.logWrapper(logConfig);
        loggerModule.logger = loggerObject;
  6. Use the logger.info, logger.debug, logger.warn and logger.error functions to log messages.
  7. All the above functions have 2 args - message as string, props as obj.
  8. Guidelines for props
    1. prompt: object
      1. key: string
      2. value: string
    2. error: object (Make sure that this is a pure error object, do not print any other values using this key)
      1. name: string
      2. stack: string
      3. status: string
      4. message: string
    3. browser: string
    4. config: string
    5. cookies: string
    6. createdBy: string
    7. isTrusted: boolean
    8. licenseType: string
    9. port: string
    10. host: string
    11. key: string
    12. message: string
    13. type: string
    14. body: string
    15. token: string
    16. sender: string
    17. wsId: string
    18. botId: string
    19. userId: string
    20. agentId: string
    21. loginId: string
    22. clientId: string
    23. channelId: string
    24. requestId: string
    25. sessionId: string
    26. messageId: string
    27. routeName: string
    28. userData: string
    29. propString: string (For all other props or any props that Dev wants to check)
  9. Installing Filebeat link
  10. The docker-compose's env vars are populated inside filebeat.
        smart-analytics:
          container_name: smart-analytics
          image: sbh/smart-analytics:dev-latest
          environment:
            - NODE_ENV=DEV
            - PORT=6790
            - KAFKA_HOST=x.x.x.x
            - KAFKA_PORT=xxxx
            - SERVICE_LOGS_PATH=x/x/x/*.log

Appendix

Installing Filebeat in Docker-Ubuntu

RUN mkdir /etc/apt/keyrings/
RUN wget -O - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor -o /etc/apt/keyrings/elasticsearch-keyring.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list
RUN apt update
RUN apt -y install filebeat=8.7.1

ElasticSearch Mappings

{
  "mappings": {
    "dynamic": false,
    "properties": {
      "infolog": {
        "properties": {
          "env": {
            "type": "text",
            "store": true
          },
          "event": {
            "type": "text",
            "store": true
          },
          "exception": {
            "type": "text",
            "store": true
          },
          "hostname": {
            "type": "text",
            "store": true
          },
          "ipaddress": {
            "type": "text",
            "store": true
          },
          "level": {
            "type": "text",
            "store": true
          },
          "loggerVersion": {
            "type": "text",
            "store": true
          },
          "servicename": {
            "type": "text",
            "store": true
          },
          "serviceVersion": {
            "type": "text",
            "store": true
          },
          "stackTrace": {
            "type": "text",
            "store": true
          },
          "timestamp": {
            "type": "date",
            "store": true
          },
          "ingesttimestamp": {
            "type": "date",
            "store": true
          },
          "message": {
            "type": "text",
            "store": true
          },
          "properties": {
            "properties": {
              "prompt": {
                "properties": {
                  "key": {
                    "type": "text",
                    "store": true
                  },
                  "value": {
                    "type": "text",
                    "store": true
                  }
                }
              },
              "error": {
                "properties": {
                  "name": {
                    "type": "text",
                    "store": true
                  },
                  "stack": {
                    "type": "text",
                    "store": true
                  },
                  "status": {
                    "type": "text",
                    "store": true
                  },
                  "message": {
                    "type": "text",
                    "store": true
                  }
                }
              },
              "browser": {
                "type": "text",
                "store": true
              },
              "config": {
                "type": "text",
                "store": true
              },
              "cookies": {
                "type": "text",
                "store": true
              },
              "createdBy": {
                "type": "text",
                "store": true
              },
              "isTrusted": {
                "type": "boolean",
                "store": true
              },
              "licenseType": {
                "type": "text",
                "store": true
              },
              "port": {
                "type": "text",
                "store": true
              },
              "host": {
                "type": "text",
                "store": true
              },
              "key": {
                "type": "text",
                "store": true
              },
              "message": {
                "type": "text",
                "store": true
              },
              "type": {
                "type": "text",
                "store": true
              },
              "body": {
                "type": "text",
                "store": true
              },
              "token": {
                "type": "text",
                "store": true
              },
              "sender": {
                "type": "text",
                "store": true
              },
              "wsId": {
                "type": "text",
                "store": true
              },
              "botId": {
                "type": "text",
                "store": true
              },
              "userId": {
                "type": "text",
                "store": true
              },
              "agentId": {
                "type": "text",
                "store": true
              },
              "loginId": {
                "type": "text",
                "store": true
              },
              "clientId": {
                "type": "text",
                "store": true
              },
              "channelId": {
                "type": "text",
                "store": true
              },
              "requestId": {
                "type": "text",
                "store": true
              },
              "sessionId": {
                "type": "text",
                "store": true
              },
              "messageId": {
                "type": "text",
                "store": true
              },
              "routeName": {
                "type": "text",
                "store": true
              },
              "userData": {
                "type": "text",
                "store": true
              },
              "propString": {
                "type": "text",
                "store": true
              }
            }
          }
        }
      },
      "LEVEL": {
        "type": "keyword",
        "store": true
      }
    }
  }
}