Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@mocks-server/logger
Advanced tools
Winston-based logger allowing to create nested namespaces. It provides:
HH:mm:ss:SS [level][...parentLabel:parentLabel:label?] message
A brief example:
const { Logger } = require("@mocks-server/logger");
// Create root logger
const logger = new Logger();
logger.setLevel("debug");
logger.info("Hello world");
// 18:41:43:16 [info] Hello world
const dbLogger = logger.namespace("db");
dbLogger.verbose("Hello from database component");
// 18:41:43:16 [verbose][db] Hello from database component
const dbConnectionLogger = dbLogger.namespace("connection");
dbConnectionLogger.debug("Connecting");
// 18:41:43:16 [debug][db:connection] Connecting
console.log(dbConnectionLogger.store);
/*
[ '18:41:43:16 [debug][db:connection] Connecting' ]
*/
console.log(logger.globalStore);
/*
[
'18:41:43:16 [info] Hello world',
'18:41:43:16 [verbose][db] Hello from database component',
'18:41:43:16 [debug][db:connection] Connecting'
]
*/
const logger = new Logger();
Logger(label?, options?)
. Returns a logger
instance.
label
(String): Label for the root namespace. Optional.options
(Object): Optional.
level
(String): - Initial level, can be one of silent
, error
, warn
, info
, verbose
, debug
or silly
.storeLimit
(Number): - Limit of logs to store in the root namespace store
array. The option will be inherited by all children namespaces. Default is 1000.globalStoreLimit
(Number): - Limit of logs to store in the global store
array, which stores logs from all nested namespaces. Default is 1000.error(message)
: The message will be logged always except if the current level
is silent
.warn(message)
: The message will be logged always except if the current level
is error
or silent
.info(message
: The message will be logged whenever the current level
is not error
, warn
or silent
.verbose(message)
: The message will be logged whenever the current level
is upper or equal than verbose
.debug(message)
: The message will be logged whenever the current level
is upper or equal than debug
.silly(message)
: The message will be logged whenever the current level
is upper or equal than silly
.setLevel(level, [options])
: Sets the logger current log level for the current namespace and all children namespaces recursively.
level
(String): Level can be one of silent
, error
, warn
, info
, verbose
, debug
or silly
.options
(Object):
transport
(String): The Winston
transport in which the level has to be set. Can be one of console
or store
. If not provided, the level is set to all transports. In the root logger, changes in the store
transport will be applied also to the globalStore
transport.propagate
(Boolean): Propagates the level change to all children namespaces recursively or not. Default is true
.pinned
(Boolean): When true
, next level changes coming from propagations will be ignored and the transport/transports will keep the defined level
. Default is false
.forcePropagation
(Boolean): When true
, the propagation will ignore pinned
levels and will always override them.namespace(label)
: Creates and returns a new child namespace or returns an already existent one when the label
already exists. The returned namespace has the same Logger
methods described here. The created namespace will inherit the current namespace level.
label
(String): Label for the new namespace. It will be displayed as part of the log [label]
, appended to parent namespaces labels.cleanStore()
Empties the namespace store array.onChangeStore(callback)
: Allows to add a listener that will be executed whenever a log is added to the current namespace store. It returns a function that removes the listener once executed.
callback()
(Function): Callback to be executed.onChangeGlobalStore(callback)
: Allows to add a listener that will be executed whenever a log is added to the global store. It returns a function that removes the listener once executed.
callback()
(Function): Callback to be executed.store
: Returns an array with logs stored in the current namespace.globalStore
: Returns an array with logs stored in all namespaces, including those from the ancestors. There is only one global namespace for each Logger
instance, no matter the amount of namespaces it has.label
: Getter returning the namespace label.level
: Getter returning the current namespace level.root
: Getter returning the root namespace instance.FAQs
Namespaced logger
The npm package @mocks-server/logger receives a total of 16,250 weekly downloads. As such, @mocks-server/logger popularity was classified as popular.
We found that @mocks-server/logger 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.