Skip to content

worktile/rocket-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ rocket-logger

a sample logger wrapper base on winston 3.x

Features

  1. support log to MongoDB;
  2. quickly create owner logger by configuration options;

Installation

npm install @worktile/rocket-logger --save

Usage

const options = {
    db: {
        mongodbServer: "mongodb://localhost:27017/wt-log",
        collection: "", // default logs
        errorCollection: "", // default errors
        mongodbOptions: {}, // Mongodb connect options
    },
    console: true,
    file: {
        filename: "access.log",
        errorFileName: "error.log",
        dirname: "logs",
        maxsize: 1024 * 1024 * 10,
        maxFiles: 10
    }
};
const logger = RocketLogger.create(options);

logger.debug("this is debug message");
logger.info("this is info message");
logger.warn("this is warn message");
logger.error("this is error message");
logger.info("this is info message", {
    action: "add user"
});

logger.error("this is error message", new Error("Custom Error"));
logger.error(new Error("Custom Error"));
logger.error(new Error("Custom Error"), {
    action: "Get Custom Data"
});

Releases

No releases published

Packages

No packages published