Logtape – Logging Library that releases Devs JS | Korben

Will I add logs to facilitate tuning or let my users manage in the dark?

It is a classic dilemma of the developer of libs to which you can either save your dependence logging That no one asked to get rid of all key information.

Logtape has just solved this old puzzle as a world (well, old as NPM) with an approach that has a class, you will see!

Logtape is therefore a JavaScript/TypeScript library, which after a minimum and gzipped weighs only 5.3 kB. Accepts philosophy “Library-Tirst” With zero addiction, which means that your protocols remain completely invisible and quiet until the end user decides to configure. It’s great for privacy and even more great not to clean up the console of your users.

The creator of Logtape, Dahlia (Hong Minhee), apparently understood that the world JavaScript needs a solution that works everywhere, and when I say everywhere, it’s really everywhere: Node.js,, Day,, BunWeb browsers and even edges. A single API, one code and turns on all platforms. Logtape has a system Hierarchical category This allows you to organize your protocols by modules, submodules and even specific functions. This is how you can only activate the logs of your authentication module in production to monitor the error without drowned under the reports of the rest of the application.

Logtape uses Literary template From JavaScript to create natural reports of the protocol with surrogate symbols. So there is no need to take into account straps such as barbarian or manually format your objects. You simply write logger.info\User $ {userid} logged in to $ {timestamp} \ “ and logtape will take care of the rest. And if you have sensitive data, do not panic, the library contains the system Automatic editors Hide confidential information.

Logtape architecture is also designed for performance: Sinks (your protocol goals) are non -blocked with an asynchronous leveling system. This means that your logs never affect the performance of your application, even if you log in as a fool. And thankslazinessExpensive calculations are only performed if the corresponding level of the protocol is active. Therefore, you can give super detailed tuning protocols without worrying about the impact on production.

For developers who already have an established infrastructure of mining, Logtape offers adapters for Winston AND Pine. You can therefore gradually migrate without having to do everything at once. And for those who want advanced functions, the ecosystem is already rich: it decreases for AWS cloudwatch, Windows event protocol, nice printing for development and even support for ophthalmmetry.

Here is a basic example that shows all the strength of the system:

await configure({
sinks: { 
console: getConsoleSink(),
file: getFileSink("app.log")
},
loggers: (
{ category: "my-app", lowestLevel: "debug", sinks: ("console") },
{ category: ("my-app", "database"), lowestLevel: "info", sinks: ("file") }
)
});

Version 1.0.0, which has just been published, ensures the stability of the API, which is calming for those who want to accept logtape in production. And with functions as Structured logging (Ideal for cloud environments), the possibility of adding contextual data to all your protocols and a system of expandable filters, despite youth, we really deal with mature solutions.

For curious who want to see Logtape in action, installation is Fastrot: npm install logtape And you left.

Documentation is also very clear, examples numerous and the community is already starting to create plugins and extensions, so even though we already have Winston, Pino, Bunyan and a dozen other solutions in JavaScript, Logtape brings something really new with its approach First library and his philosophy of zero impact.

Do not hesitate to look!

Source

(Tagstotranslate) Logtape

Leave a Comment