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

@herp/bs-winston

v0.5.0

Published

```ocaml module Winston : sig module type LogLevel module type LOG

Downloads

1

Readme

bs-winston

Bucklescript bindings for (subset of) winston@3.x

module Log = Winston.SyslogMake(struct
    let transports = [Winston.Transport.console ()]
    let formats = [
      Winston.Format.label ~label: "test" ~message: false;
      Winston.Format.timestamp ();
      Winston.Format.json ();
    ]
    let level = `Debug
  end)

let () =
  Log.log `Info "Hello World" ();
  Log.log `Crit "OCaml. Not Ocaml." ();
  Log.log `Err "Oops" ();;

contents

module Winston : sig
  module type LogLevel
  module type LOG

  module Transport
  module Format
  module Make
  module SyslogMake
  module NpmMake
end

Transport submodule for transports

module Transport : sig
  type t
  val console : ?eol:string -> unit -> t
  val file : ?eol:string
          -> ?dirname:string
          -> ?filename:string
          -> unit
          -> t
end

We support Console and File, with partial options.

Format submodule for formats

module Format : sig
  type t
  val label : label:string -> message:bool -> t
  val json : ?space:int -> unit -> t
  val timestamp : ?format:string -> unit -> t
end

LogLevel signature

This signature represents the first argument of Make.

module type LogLevel = sig
  type t

  val string_of_t : t -> string
  val enabled : t list
end

Make functor

This functor generates a logger module.

LOG signature represents the logger module.

module type LOG = sig
  type t

  val log: t -> string -> ?meta:string Js.Dict.t -> unit -> unit
end
module Make(Level : LogLevel)(Conf : sig
    val transports : Transport.t
    val formats : Format.t list
    val level : Level.t
  end)
  : LOG with type t = Level.t

SyslogMake and NpmMake functor

These functors are ones partially applied Make.

module SyslogMake(Conf : sig
    val transports : Transport.t
    val formats : Format.t list
    val level : syslog_t
  end)
  : LOG with type t = syslog_t
module NpmMake(Conf : sig
    val transports : Transport.t
    val formats : Format.t list
    val level : npm_t
  end)
  : LOG with type t = npm_t

and we provide syslog_t and npm_t as polymorphic variant type

type syslog_t = [
  | `Emerg
  | `Alert
  | `Crit
  | `Err
  | `Warn
  | `Notice
  | `Info
  | `Debug
]

type npm_t = [
  | `Err
  | `Warn
  | `Info
  | `Http
  | `Verbose
  | `Debug
  | `Silly
]

These are alias of Winston_syslog.LogLevel.t and Winston_npm.LogLevel.t

module Winston_syslog.LogLevel : LogLevel = struct
  type t = [
      | `Emerg  [@bs.as   "emerg"]
      | `Alert  [@bs.as   "alert"]
      | `Crit   [@bs.as    "crit"]
      | `Err    [@bs.as   "error"]
      | `Warn   [@bs.as "warning"]
      | `Notice [@bs.as  "notice"]
      | `Info   [@bs.as    "info"]
      | `Debug  [@bs.as   "debug"]
  ] [@@bs.deriving jsConverter]

  let enabled = [`Emerg; `Alert; `Crit; `Err; `Warn; `Notice; `Info; `Debug]
  let string_of_t x = tToJs x
end
module Winston_npm.LogLevel : LogLevel = struct
  type t = [
    | `Err     [@bs.as   "error"]
    | `Warn    [@bs.as    "warn"]
    | `Info    [@bs.as    "info"]
    | `Http    [@bs.as    "http"]
    | `Verbose [@bs.as "verbose"]
    | `Debug   [@bs.as   "debug"]
    | `Silly   [@bs.as   "silly"]
  ] [@@bs.deriving jsConverter]

  ......
end

You can follow these implementatoins to write custom module denoting LogLevel.

License

See LICENSE