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

msteams-logger

v1.0.2

Published

A logging utility using MS Teams inbound webhooks.

Downloads

16

Readme

msteams-logger

A simple utility to post messages to Microsoft Teams using inbound webhooks. For integrators, this is useful for logging transactions to a user-monitored channel where others can see the messages and take action if needed.

Usage

Instantiation

var webhook = 'your inbound webhook here';

var logger = new MSTeamsLogger(webhook,
  "test environment",
  "Apigrate Time-Tracking App"
);

In the above simple example, the username for each MS Teams message will be set to test environment and the application_name will be Apigrate Time-Tracking App.

By convention, username is often used to store environment or host name and application_name is used to identify the name of the app making the logging call from that environment. You are, of course, free to implement your own conventions.

Here is a more detailed instantiation that includes additional information to be recorded on every logging call.

var webhook = 'your inbound webhook here';

var logger = new MSTeamsLogger(webhook,
  "test environment",
  "Apigrate Time-Tracking App",
  {
    fields: {
      build: "2022.001",
      branch: "main"
    }
  }
);

In this case, build and branch fields will be added to every log entry produced by the logger instance.

Logging

Each log message must have the following parameters:

  1. true/false indicating success or failure
  2. the log message (i.e. a summary)
  3. a more detailed message (optional). This could be log details, stack trace or other detailed information for the message (typically more useful to provide troubleshooting info on errors).

Here's how to post a simple "success" message.

logger.log(
  true,
  'That worked.'
);

It is possible include more detail in log messages. Provide a more detailed message (up to 7500 characters) if you like. Note that this detailed message will be formatted in fixed-font code block immediately following the summary message for readability (newline characters are respected by Slack in the formatting). Additionally, the fields parameter allows you to specify additional data that may be helpful for reporting or troubleshooting on specific log messages.

logger.log(
  true,
  'Invoice Created.',
  'Found customer.\nThere are 3 invoice lines.\nThe total amount is $107.80',
  {
    customer_id: 28390,
    invoice_id: 123789
  }
);

Error log messages (as shown below) are more useful when they include detailed information to allow consumers to troubleshoot more effectively.

logger.log(
  false,
  'Invoice was not created.',
  'Found customer.\nException processing invoice lines.\nThe quantity is missing for the line with product 1234879.',
  {
    customer_id: 28390,
    product_id: 1234879,
    product_sku: 'TS4921'
  }
);

Here's how these look in Teams! Log Message Examples