logger
Probably the simplest logger out there.
How to Use it
Use it in the Browser or Node.js
const {Logger} = require('@voliware/logger');
const logger = new Logger("App", {
level: "debug",
timestamp: "utc"
});
logger.debug("Initializing");
Use it for File Logging in Node.js
const {FileLogger} = require('@voliware/logger');
const filelogger = new FileLogger("App", {
context: "User",
filepath: "/path/to/file.log",
maxlogs: 10000,
maxsize: 1024 * 1000,
});
logger.info("Logged in");
Use it for MongoDB Logging in Node.js
const Logger = require('@voliware/logger');
const db = new Logger.Database({
name: "my-collection",
collection_names: ['logs']
});
await this.db.initialize();
this.collection = await this.db.getCollection('logs')
const mongodblogger = new MongoDbLogger("App", {
})
API
logger.verbose("verbose log");
logger.debug("debug log");
logger.info("info log");
logger.warning("warning log");
logger.error("error log");
logger.log("hello", "debug");
logger.log("hello again", Logger.level.debug);
logger.timestamp = "numeric";
logger.level = "info";
logger.enabled = false
Node
Install with node package manager
npm install @voliware/logger
Include in a file
const Logger = require('@voliware/logger');
Browser
Include in a file
<script src="https://cdn.jsdelivr.net/npm/@voliware/logger/dist/logger.min.js"></script>