
Security News
CISA Rebuffs Funding Concerns as CVE Foundation Draws Criticism
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
A logger utlity for Node.js using adapters.
Scrib itself is just an event emitter with some fancy methods. The real wok is done by its adapters. When you initialize Scrib, you load one or more adapters for it. When you tell Scrib to log something, it's going to tell every adapter about your log and they'll handle it in their way e.g. send an e-mail or write to a log file.
For Scrib everything is a message. Every error, warning or log is a message. Each message has following properties:
message
: A short message describing itselfdata = {}
: Optional data (e.g. API response)priority = 0
: The message's importance as a number equal or greater than 0id = null
: An ID to specify the message. Useful for errorscategory = null
: A category to group messages (e.g. Database)time = Date.now()
: The timestamp when we loggednpm install scrib
var Scrib = require("Scrib"),
logger = new Scrib({
"local": {
file: "./log.txt"
},
function(e) {
// If during Scrib's startup an error appeared we should stop the process
if(e) throw e;
logger.put("Hello World");
});
This example loads the local-adapter for Scrib. After Scrib finished loading it's going to call the callback.
scrib-local
: Write logs into log filesWhen you want to write one yourself, have a look at this.
new Scrib(adapters, callback)
Initalizes a new logger. adapters
is a object where each key is an adapter's name and the value is an config object which is going to be passed into the adapter.
Scrib first tries to require scrib-{ADAPTER}
and then the file directly (see the code).
callback
is a callback where the first argument is an error.
new Scrib({
// Will require scrib-local
"local": {},
// Wll require ./adapter.js
"./adapter.js": {},
function(e) {}
);
Scrib.put(message, data, priority, id, category)
The simplest way to log something:
logger.put("API limit reached", { limit: 5000 }, 10, "API_LIMIT", "API");
Scrib.register(id, message, priority, category)
Scrib.log(id, data)
If we don't want to call Scrib.put
each time using priority, category and message, we can simply register a message and then log it using Scrib.log
and the ID:
logger.register("API_LIMIT", "API limit reached", 10, "API");
logger.log("API_LIMIT", { limit: 5000 });
Scrib.catch(error, data)
This transforms an Error
object into a message and then logs it:
try {
throw new Error("Ups");
} catch(e)
logger.catch(e);
}
If e
is an error thrown by libuv, Scrib will trun it into a message: message is e.description
, id is e.code
, data.errno is e.errno
.
Additional data from e
is merged into data (see code).
Scrib inherits from EventEmitter
and has its functions.
log
: Emitted for each logid:ID
: Emitted for each log if it's ID is ID
, e.g. id:API_TIMEOUT
category:CATEGORY
: Emitted for each log if it's category is category
, e.g. category:API
git clone git://github.com/Acconut/scrib.git
cd scrib
npm install
npm test
Licensed under the MIT License.
FAQs
A logger utility
The npm package scrib receives a total of 2 weekly downloads. As such, scrib popularity was classified as not popular.
We found that scrib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.