
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@luckbox/logger-factory
Advanced tools
Easy to use logger with several levels of logging as well as different adapters that can be used separately or in combinations
This logger factory produces Logger instances that can have different prefixes, but all share the same logging level that is set for the LoggerFactory instance. Note that logging level is configured per adapter, i.e. you can be more verbose with one adapter and less verbose for another.
The following example creates a LoggerFactory instance, using only a console adapter with log level info,
and that instance is used to create two Logger instances with Classname and Classname2 prefixes respectively.
const LoggerFactory = require('./LoggerFactory');
const infoLoggerFactory = new LoggerFactory({
adapters: [{
name: Adapters.Console,
config: {
logLevel: 'info'
}
}]
});
const infoLogger = infoLoggerFactory.create('Classname');
const anotherInfoLogger = infoLoggerFactory.create('Classname2');
The following example creates a LoggerFactory instance, using only two adapters - console and sentry, with log levels info and warn respectively,
meaning that all messages above info will only be logged via the Console adapter, while warn and above will also be logged via Sentry adapter.
After that, similarly to our previous example, that LoggerFactory instance is used to create two Logger instances with Classname and Classname2 prefixes respectively.
const LoggerFactory = require('./LoggerFactory');
const infoLoggerFactory = new LoggerFactory({
adapters: [
{
name: Adapters.Console,
config: {
logLevel: 'info'
}
},
{
name: Adapters.Sentry,
config: {
logLevel: 'warn',
dsn: 'https://5637ee1e65504e02b1ba62255ac1f23a@youserver.com/6',
environment: 'testing',
}
}
]
});
const infoLogger = infoLoggerFactory.create('Classname');
const anotherInfoLogger = infoLoggerFactory.create('Classname2');
constructor ({ adapters }) - Creates an instance LoggerFactory instance with the requested array of adapters. List of the supported adapters,
along with their configuration requirements, follows below.create(prefix?: string) - Creates an instance of the logger, using already specified adapters.The following is a list of all supported adapters, along wit an example usage of each of them. The possible logging levels are the same for each of the adapters and are listed below this list.
Default configuration (works for all adapters):
skipTimestamps Whether to include the timestamps in the logged message. Can be turned off if using kubernetes,
since it has integrated functionality to timestamp all messages. Defaults to false.logLevel - The minimum logging level that will be logged with that adapter.Console adapter has no additional configuration.
const LoggerFactory = require('./LoggerFactory');
const infoLoggerFactory = new LoggerFactory({
adapters: [{
name: Adapters.Console,
config: {
logLevel: 'info'
}
}]
});
const infoLogger = infoLoggerFactory.create('Classname');
const anotherInfoLogger = infoLoggerFactory.create('Classname2');
Sentry has the following additional configuration settings:
dsn - Client key, used by Sentry to determine where to send the event toenvironment - Used to separate errors from different environmentsdebug - Whether to enable Sentry adapter in debug mode (NOTE: even in debug mode, not working Sentry server
will not crash the code). Defaults to false.const LoggerFactory = require('./LoggerFactory');
const infoLoggerFactory = new LoggerFactory({
adapters: [{
name: Adapters.Sentry,
config: {
logLevel: 'warn',
dsn: 'https://5637ee1e65504e02b1ba62255ac1f23a@yoursentryserver.com/6',
environment: 'testing',
debug: false,
}
}]
});
const infoLogger = infoLoggerFactory.create('Classname');
const anotherInfoLogger = infoLoggerFactory.create('Classname2');
The following log levels are supported, listed from least verbose to the most verbose:
off - Nothing is loggedsystem - System messages (used via .system()) are loggederror - Error messages (used via .error()) are loggedwarn - Warn messages (used via .warn()) are loggedinfo - Info messages (used via .info()) are loggeddebug - Debug messages (used via .debug()) are loggedNote that in all cases, when setting a value, all less-verbose types of messages are also logged,
for example if you set warn as log level, off, system and error are also logged.
The following methods can be called on a Logger instance:
system(message) - The provided message is logged via console.log if the configured log level allowserror(message) - The provided message is logged via console.error if the configured log level allowswarn(message) - The provided message is logged via console.warn if the configured log level allowsinfo(message) - The provided message is logged via console.info if the configured log level allowsdebug(message) - The provided message is logged via console.log if the configured log level allowsclear - Console is clearedFAQs
Easy to use logger with several levels of logging as well as different adapters that can be used separately or in combinations
We found that @luckbox/logger-factory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.