0.0.0 • Published 2 years ago
deaf v0.0.0
deaf.js
Installation
npm install deaf
Usage 🚀
Importing
const deaf = require("deaf");
Configuration
use this if you want to save your logs to files automatically
- the logs property is meant for basic logging
- the reqs property is meant for http requests
deaf.config ({
logs: "./logs.txt",
reqs: "./requests.txt"
});
Basic Logging
deaf.success("successfully fetched data");
deaf.error("user is not defined");
deaf.warning("this method is deprecated and will be removed in future versions");
deaf.info("u/spez logged in");
HTTP Requests
deaf.request(path, status, source);
deaf.request("/", 418, "192.0.2.0");
deaf.request("/login", 100, "192.0.2.255");
deaf.request("/profile", 200, "192.0.2.104");
deaf.request("/news", 502, "192.0.2.13");
// you can also use the shorter way instead
deaf.req(path, status, source);
Reading Logs
you can either read the logs file or the reqs file and either use promises or await
deaf.read("logs")
.then(data => console.log(data))
.catch(err => console.log(err));
let data = await deaf.read("reqs");
console.log(data);
Express Example
here's an example how you could use this library with the express.js framework
const express = require("express");
const deaf = require("deaf");
const app = express();
app.listen(3000, () => deaf.info("server is waiting for requests"));
deaf.config ({
logs: "./logs.txt",
reqs: "./requests.txt"
});
app.get("/", (req, res) => {
deaf.request(req.url, 200, req.connection.remoteAddress);
res.sendStatus(200);
});
0.0.0
2 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
0.0.1-alpha.1
4 years ago
0.0.1-alpha.0
4 years ago