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

@helios-interactive/crow

v1.2.0

Published

JS logging client

Downloads

17

Readme

Crow

A JS logging client meant to be used with Woodpecker.

Installation

npm install @helios-interactive/crow --save

Usage

Node / Commonjs

var crow = require("@helios-interactive/crow");
crow.setUrl("<url of woodpecker>");
crow.setApplication("<application name>");
crow.warn("A message to be logged to woodpecker")

Browser

<script src="./dist/crow.min.js"></script>
<script>
    crow.setUrl("<url of woodpecker>");
    crow.setApplication("<application name>");
    crow.warn("A message to be logged to woodpecker")
</script>

AMD

define(['crow'], function (crow) {
    crow.setUrl("<url of woodpecker>");
    crow.setApplication("<application name>");
    crow.warn("A message to be logged to woodpecker")
});

Module

import { crow } from '@helios-interactive/crow';

crow.setUrl("<url of woodpecker>");
crow.setApplication("<application name>");
crow.warn("A message to be logged to woodpecker")

Default Logger instance & custom logger instances

Crow can be used directly as a logger instance, or create additional loggers. This is useful if we intend to log to multiple applications or Woodpecker instance.

var logger = crow.createLogger();
logger.setUrl("<url of woodpecker>");
logger.setApplication("<application name>");
logger.warn("A message to be logged to woodpecker")

Methods

createLogger(options)

creates a new crow logger instance. You can pass in configurations as parameter.

Usage

var logger = crow.createLogger() var loggerWithConfig = crow.createLogger({url: "http://localhost:4000", application: "FooBar", devMode: true})

configure(options)

configures the logger. options include woodpecker instances' url, and application name.

setUrl(url)

Sets the url for crow. This should match the url for your woodpecker instance.

Parameters

url - The url of the woodpecker instance that is being run.

Usage

crow.setUrl('http://localhost:4000')

setApplication(application)

Sets the application for crow. This will determine what logfile the requests go to.

Parameters

application - The name of the current application.

Usage

crow.setApplication('Foobar')

setDevMode(devMode)

Sets crow into dev mode. When in dev mode crow will not attempt to log to woodpecker, and will instead only log to console. This can be used in development, but should not be used in production.

Parameters

devMode - Boolean - true will set crow to devMode. false will set crow back to normal so that it logs to woodpecker. By default crow is not in devMode.

Usage

crow.setDevMode(true)

info([data][, ...args])

Sends an INFO log to woodpecker

Parameters

Accepts arguments in the same manner as console.log.

data - Any

...args - Any

Usage

crow.info('An info log message.')

crow.info('An info log message.', 'with multiple arguments')

crow.info('An info log message.', 'with multiple arguments', ['of', 'different', 'types'])

log([data][, ...args])

Sends an INFO log to woodpecker. Alias of crow.info

Parameters

Accepts arguments in the same manner as console.log.

data - Any

...args - Any

Usage

crow.log('An info log message.')

crow.log('An info log message.', 'with multiple arguments')

crow.log('An info log message.', 'with multiple arguments', ['of', 'different', 'types'])

debug([data][, ...args])

Sends an DEBUG log to woodpecker

Parameters

Accepts arguments in the same manner as console.log.

data - Any

...args - Any

Usage

crow.debug('An debug log message.')

crow.debug('An debug log message.', 'with multiple arguments')

crow.debug('An debug log message.', 'with multiple arguments', ['of', 'different', 'types'])

warn([data][, ...args])

Sends an WARN log to woodpecker

Parameters

Accepts arguments in the same manner as console.log.

data - Any

...args - Any

Usage

crow.warn('An warn log message.')

crow.warn('An warn log message.', 'with multiple arguments')

crow.warn('An warn log message.', 'with multiple arguments', ['of', 'different', 'types'])

error([data][, ...args])

Sends an ERROR log to woodpecker

Parameters

Accepts arguments in the same manner as console.log.

data - Any ...args - Any

Usage

crow.error('An error log message.')

crow.error('An error log message.', 'with multiple arguments')

crow.error('An error log message.', 'with multiple arguments', ['of', 'different', 'types'])

fatal([data][, ...args])

Sends an FATAL log to woodpecker

Parameters

Accepts arguments in the same manner as console.log.

data - Any ...args - Any

Usage

crow.fatal('An fatal log message.')

crow.fatal('An fatal log message.', 'with multiple arguments')

crow.fatal('An fatal log message.', 'with multiple arguments', ['of', 'different', 'types'])

Life Cycle Callback Functions

Node Only

crow.onSuccess = callback;

Property that allows setting a callback function to call whenever crow receives a successful response from Woodpecker

Callback Arguments

data - Object containing statusCode, statusMessage, uri, and body sent with request

Usage

crow.onSuccess = function(data){console.log(data)};

crow.onFailure = callback;

Property that allows setting a callback function to call whenever crow throws an error when attempting to make a request to Woodpecker

Callback Arguments

err - error object with err.message including attempted payload message

Usage

crow.onFailure = function(err){console.error(err); console.log(err.message);};