loglevelnext is a modern logging library for Node.js and modern browsers, written with modern patterns and practices which provides log level mapping of the
For browser use, or use in client-side applications,
loglevelnext should be bundled by your preferred bundler or compiler, such as Rollup.
First thing's first, install the module:
npm install loglevelnext --save
Users can choose to use
loglevelnext in Node.js or in the client (browser).
const log = ;log;
loglevelnext ships supporting the following log level name-value
TRACE: 0DEBUG: 1INFO: 2WARN: 3ERROR: 4SILENT: 5
loglevelnext in Node.js the default export will be an instance of
LogLevel wrapped with some extra sugar.
LogLevel for documentation of all methods and properties of every log instance, including the default instance.
These methods correspond to the available log levels and accept parameters identical to their
console counterparts. e.g.
console;console;// ... etc
Returns a new
LogLevel instance. The
options parameter should be an
Object matching the options for the
LogLevel instances created are cached. Calling
create with a previously used
name will return the cached
LogLevel instance. To create a different instance with the same
name, assign a unique
id property to the
Array [ Class ]
Array containing the factory classes available within
to outside modules. Particularly useful when creating plugins. eg.
const log = ;const MethodFactory = logfactories;...
Array [ LogLevel ]
Array containing references to the currently instantiated loggers.
Factories aka Plugins
If you're used to using plugins with
loglevel, fear not. The same capabilities
are available in
loglevelnext, but in a much more straightforward and structured
loglevelnext supports by way of "Factories." A
Factory is nothing more
than a class which defines several base methods that operate on the
and provide functionality to a
LogLevel instance. All factories must inherit from the
MethodFactory class, and may override any defined class functions.
For an example factory, please have a look at the
which provides similar functionality as the loglevel-prefix plugin,
and is the factory which is used when a user passes the
prefix option to a
loglevelnext is a logging library for Node.js and modern browsers, which means the latest versions of the major browsers. When bundling or compiling
loglevelnext for use in a browser, you should ensure that appropriate polyfills are used. e.g. Internet Explorer typically requires polyfilling both
This project originated as a fork of the much-loved loglevel module, but has diverged and has been rewritten, and now shares similarities only in functional intent.