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

ac-logger

v3.0.0

Published

Unified logging function for all backend applications of AdmiralCloud. Use it instead of Winston (it is based on Winston)

Downloads

118

Readme

AC Logger

Unified logging function for all backend applications of AdmiralCloud. Use it instead of Winston (it is based on Winston)

The purpose of the little app is to make sure that all applications use the same log format/notations.

Node.js CI

Usage

Use it like Winston!

const aclog = require('ac-logger')

const logConfig = {
  prefixFields: [
    { field: 'jobId', short: 'J' },
  ],
  applicationLogs: {
    enabled: true // if true, JSON formatted, machine readable application logs will be created into logs directory
  }
}

app = {} // 
app.log = aclog({ prefixFields: logConfig.prefixFields }).acLogger

// DEPRECATED
let logMeta = {
  fileName: 'UploadS3',
  functionName: 'upload',
  jobId: 123 // prefixField
}
app.log.info('Message for %s', 'some string', { meta: logMeta })
// -> INFO UploadS3 | upload | J 193 | Message for some string

// MODERN APPROACH (that is best suited for machine and human readability)
app.log.info('Message for some string', { functionName: 'upload', ... }) // all meta data like "functionName" will be available in application logs

Error logging

If you want to add the stack (from an error instance) to an error log use it like this:

try {
  let data = Buffer.from()
}
catch(e) {
  app.log.error('We have encountered an error in module %s', 'Module name', { e })
}

This will result in a nice log entry and above that a console.error message with the stack from e.

If you want to log a custom error message, not an error instance, you can use it like this:

let errorMessage = {
  message: 'user_emailWrong',
  code: 1234
}
app.log.error('We have encountered an error in module %s - %j', 'Module name', errorMessage)

// -> We have encountered an error in module Module name - { message: 'user_emailWrong', code: 1234 }

#Helper functions To improve the logging even more, there are several helper functions available

Headline

Used in bootstrapping to seperate sections

aclog().headline({ headline: 'AWS' })
// -> ****** AWS ********

functionStartLine

Used in to log the beginning of a function

aclog().functionStartLine({ headline: 'my function' })
// -> ______ My function ______

listing

Used in bootstrap

aclog().listing({ field: 'servername', value: 'localhost' })
// -> Servername:        localhost

TBC

Links

License

MIT License Copyright © 2009-present, AdmiralCloud AG, Mark Poepping