Skip to content

cca-io/rescript-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rescript-logger

Simple logger library for ReScript apps.

Design Goals

  1. Do not require a PPX, but still provide a way to include the module name in the log output.
  2. Pluggable logger implementation so that code shared between e.g. React and React Native can use a platform-specific implementation.

Installation

# yarn
yarn add @cca-io/rescript-logger

# or npm
npm install @cca-io/rescript-logger

Then add rescript-logger to the dependencies in your bsconfig.json, e.g.:

{
  "name": "my-app",
  ...
  "bs-dependencies": ["@rescript/react", "@cca-io/rescript-logger"],
  ...
}

Usage

Example:

module Log = unpack(ResLogger.make(__MODULE__))

Log.info("Starting")

// ...

Log.error2("Startup error", error)

The actual logger implementation is pluggable, so it can be swapped out e.g. for usage with React Native:

ResLogger.setLoggerImpl(module(MyNativeLoggerImpl))