@cca-io/rescript-logger
v2.0.0
Published
Simple logger library for ReScript apps
Downloads
5
Readme
rescript-logger
Simple logger library for ReScript apps.
Design Goals
- Do not require a PPX, but still provide a way to include the module name in the log output.
- 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))