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

loggy-discord

v1.0.2

Published

A simple package that allows you to put your logs on your Discord server.

Downloads

5

Readme

Loggy

A package that allows you to put your logs on your Discord server.

image

https://www.npmjs.com/package/loggy-discord

Features

Get the production logs of your app directly on your Discord server, using different methods, with different message formats, and chose if you want to get tagged or not on these messages.

No more struggling with the Heroku console or other prod platforms where it's not practical to see what's hapenning on your app... You can now use these different available methods with Loggy :

  • loggy.log("message") 👉 a simple log
  • loggy.alert("message") 👉 a log displayed in yellow
  • loggy.error("message") 👉 an error log displayed in red

image image

  • loggy.save() 👉 save a log in a secondary channel, to be sure to find it later

image

  • loggy.client() 👉 to first connect to the bot client
  • loggy.quit() 👉 to quit Loggy in your app process if you need it

Get Ready

NPM

npm install loggy-discord

Discord Bot Integration Setup

  • go to your Discord developper portal : https://discord.com/developers/applications
  • create an app called "Loggy"
  • got to the created app, and create a bot in it called... "Loggy" (oh wow, surprising)
  • don't forget to copy the secret Token of your bot to paste it in your .env file later

image

If you want to add a profile picture to your Loggy bot, here is his logo : https://jker.fr/loggy-logo

Discord server preparation

Create two channels in your own Discord server :

  • one to post logs
  • and one to post saved logs (channel 2)
  • put notifications settings of these chans on "only mentions"

Environments variables

Put some env vars in a .env file, located at the root of your app :

// you got it early, as shown above
DISCORD_LOGGY_TOKEN=your_secret_discord_bot_token 
// right click on your channel -> copy ID
CHANNEL_ID_1=discord_channel_id_where_you_want_logs
CHANNEL_ID_2=discord_channel_id_where_you_want_save_logs
// right click on your profile pic somewhere in a chat -> copy ID
USER_ID=user_you_want_to_tag_in_messages

How to use it in your app

import loggy from "loggy-discord"; 
// note that, to use "import" in a nodeJS env, you have to add the line "type" : "module" in your package.json
// or use : 
// const loggy = require("loggy-discord")

  // START BOT
await loggy.client(
  // set param to true for the types of messages where you want to be tagged on Discord
  // don't write the param line if you don't want to be tagged on this type of message
  // the example below : loggy.log() will not tag you on Discord, but .error(), .alert() and .save() will
  {
    // logUserTag : true,
    errorUserTag : true,
    alertUserTag: true,
    saveUserTag : true
  }
);

// LOG SOME STUFF
loggy.log("This is an absolutely normal log.");

// pass a second arg set to "true" if you exceptionally want to be tagged on this particular .log line
loggy.log("Always so normal log, but you are tagged on this one.", true);

loggy.error("A wild error appears !");

loggy.alert("An alert that alerts for alerting things.");

loggy.save("Oh really, a message saved in another channel, that's awesome !");

// AND QUIT LOGGY IF YOU NEED IT
loggy.quit();

// use async / await in your app process to be sure that loggy.quit() is executing only after messages are sent
// you can use await on loggy's methods (example : await loggy.log())

Author

Contributor(s)

A big thank to

🔗 Links

website linkedin twitter