scalajs-io / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WinstonDailyRotateFile API for Scala.js

winston-daily-rotate-file - A transport for winston which logs to a rotating file each day..

Description

A transport for winston which logs to a rotating file each day.

Build Dependencies

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

Before running the tests the first time, you must ensure the npm packages are installed:

$ npm install

Then you can run the tests:

$ sbt test

Examples

import io.scalajs.nodejs.process
import io.scalajs.npm.winston
import io.scalajs.npm.winston._
import io.scalajs.npm.winston.transports._
import scalajs.js

WinstonDailyRotateFile // let's ensure the daily rotate file package is loaded

val transport = new winston.transports.DailyRotateFile(new DailyRotateFileOptions(
    filename = "./src/test/resources/rotating.log",
    datePattern = "yyyy-MM-dd.",
    prepend = true,
    level = if (process.env.get("ENV").contains("development")) "debug" else "info"
))

val logger = new winston.Logger(new ConfigurationOptions(
    transports = js.Array(transport)
))

logger.info("Hello World!")

Artifacts and Resolvers

To add the WinstonDailyRotateFile binding to your project, add the following to your build.sbt:

libraryDependencies += "io.scalajs.npm" %%% "winston-daily-rotate-file" % "0.5.0"

Optionally, you may add the Sonatype Repository resolver:

resolvers += Resolver.sonatypeRepo("releases") 

About

A transport for winston which logs to a rotating file each day.

License:Apache License 2.0


Languages

Language:Scala 100.0%