Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "logepi", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A tiny (Togepi-sized) package for logs, built on top of Winston.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -74,2 +74,11 @@ <img align="left" src="https://i.imgur.com/PTzwjQY.jpg" height="150px" /> | ||
### Setting up an output level | ||
In order to filter what messages are printed to the console transport, you can use the `Log.setOutputLevel()` method: | ||
```js | ||
// Limit messages to "error" level. | ||
Log.setOutputLevel("error"); | ||
``` | ||
### Using the Koa middleware | ||
@@ -76,0 +85,0 @@ |
@@ -16,2 +16,4 @@ import { Context } from "koa"; | ||
export class Log { | ||
static setOutputLevel: (logLevel: LogLevel) => void; | ||
static message: ( | ||
@@ -18,0 +20,0 @@ logLevel: LogLevel, |
@@ -82,2 +82,4 @@ const winston = require("winston"); | ||
const consoleTransport = new winston.transports.Console(); | ||
const logger = winston.createLogger({ | ||
@@ -89,6 +91,10 @@ level: "info", | ||
), | ||
transports: [new winston.transports.Console()] | ||
transports: [consoleTransport] | ||
}); | ||
module.exports = class Log { | ||
static setOutputLevel(logLevel) { | ||
consoleTransport.level = logLevel; | ||
} | ||
static message(logLevel, message, data = {}) { | ||
@@ -95,0 +101,0 @@ logger.log(logLevel, message, data); |
12255
210
182