Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
logging-utils
Advanced tools
Utilities for configuring simple log level based logging functionality on an object
Utilities for configuring simple log level based logging functionality on an object.
The log levels supported are the following:
Main module:
This module is exported as a Node.js module.
Using npm:
$ npm i --save logging-utils
// To use the logging utilties
const logging = require('logging-utils');
// Logging configuration functions
const isLoggingConfigured = logging.isLoggingConfigured;
const configureLoggingWithSettings = logging.configureLoggingWithSettings;
const getDefaultLoggingSettings = logging.getDefaultLoggingSettings;
const configureDefaultLogging = logging.configureDefaultLogging;
const configureLogging = logging.configureLogging;
// Log level constants
const ERROR = logging.ERROR;
const WARN = logging.WARN;
const INFO = logging.INFO;
const DEBUG = logging.DEBUG;
const TRACE = logging.TRACE;
const context = { a: 1, b: 2, c: 3 }; // replace with your own target object to be configured
configureDefaultLogging(context);
configureLoggingWithSettings(context, {logLevel: WARN});
const settings = {logLevel: DEBUG, useLevelPrefixes: false, useConsoleTrace: false, underlyingLogger: console};
configureLoggingWithSettings(context, settings, false);
configureLoggingWithSettings(context, settings, true);
const log = configureDefaultLogging({});
const options = undefined; // ... or any LoggingOptions you want to use to partially or fully override the default logging settings
configureDefaultLogging(context, options, console, true);
// Alternatives specifying only underlying logger or forceConfiguration
configureDefaultLogging(context, options, console);
configureDefaultLogging(context, options, undefined, true);
const options = { loggingOptions: { logLevel: DEBUG, useLevelPrefixes: true, useConsoleTrace: false } }; // replace with your own config object
const loggingSettings = getDefaultLoggingSettings(options.loggingOptions);
configureLoggingWithSettings(context, loggingSettings);
// or as an alternative to the above 2 lines, just use the following:
configureDefaultLogging(context, config.loggingOptions);
// Alternatives specifying only optional underlying logger or forceConfiguration
configureLoggingWithSettings(context, loggingSettings, console);
configureLoggingWithSettings(context, loggingSettings, undefined, true);
const options = { logLevel: DEBUG, useLevelPrefixes: true, useConsoleTrace: false }; // replace with your own config object
const loggingSettings = getDefaultLoggingSettings(options);
configureLoggingWithSettings(context, loggingSettings);
// or as an alternative to the above 2 lines, just use the following:
configureDefaultLogging(context, options);
configureLogging(context, loggingSettings, loggingOptions, underlyingLogger, false);
configureLogging(context, loggingSettings, loggingOptions, underlyingLogger, true);
// Log an error with a strack trace
context.error('Error message 1', new Error('Boom').stack);
// Log an error without a stack trace
context.error('Error message 2');
// Log a warning (or do nothing when warnings are disabled)
context.warn('Warning message 1');
// To avoid building the warning message (when warnings are disabled)
if (context.warnEnabled) context.warn('Warning message 2');
// Log an info message (or do nothing when info messages are disabled)
context.info('Info message 1');
// To avoid building the info message (when info messages are disabled)
if (context.infoEnabled) context.info('Info message 2');
// Log a debug message (or do nothing when debug messages are disabled)
context.debug('Debug message 1');
// To avoid building the debug message (when debug messages are disabled)
if (context.debugEnabled) context.debug('Debug message 2');
// To log a trace message (or do nothing when trace messages are disabled)
context.trace('Trace message 1');
// To avoid building the trace message (when trace messages are disabled)
if (context.traceEnabled) context.trace('Trace message 2');
This module's unit tests were developed with and must be run with tape. The unit tests have been tested on Node.js v4.3.2.
See the package source for more details.
core-functions
dependency to version 2.0.15core-functions
dependency to version 2.0.14core-functions
dependency to version 2.0.13core-functions
dependency to version 2.0.12LoggingSettings
& LoggingOptions
typedefs in type-defs.js
modulelogging.js
module to new type-defs.js
moduleLogging
typedefconfigureLogging
, configureLoggingWithSettings
and configureDefaultLogging
functions
to new Logging
typecore-functions
dependency to version 2.0.11JSON.stringify
instead of
Strings.stringify
to avoid verbose logging of all of console
object's properties and functionscore-functions
dependency to version 2.0.10core-functions
dependency to version 2.0.9core-functions
dependency to version 2.0.8core-functions
dependency to version 2.0.7tape
dependency to 4.6.3logging.js
module:
configureLogging
function to configureLoggingWithSettings
configureLoggingWithSettingsOrOptions
function to configureLogging
configureLoggingIfNotConfigured
functioncore-functions
dependency to version 2.0.5logging.js
module:
configureLoggingWithSettingsOrOptions
function to simplify programmatic configurationlogging.js
module:
configureLoggingIfNotConfigured
functionlogging.js
module:
configureLoggingIfNotConfigured
functionlogging.js
module:
configureDefaultLogging
function to accept a new options
argument of type LoggingOptions
to enable optional, partial overriding of default logging settingsgetLoggingSettingsOrDefaults
function to getDefaultLoggingSettings
logging-utils
configuration API to synchronize with similar changes done to aws-core-utils/stages
configuration and aws-stream-consumer/stream-processing
configuration.
configureLogging
function API to replace multiple arguments with single settings
argumentgetLoggingSettingsOrDefaults
function to facilitate overriding default settingsconfigureDefaultLogging
function to use new getLoggingSettingsOrDefaults
functionLoggingSettings
and LoggingOptions
to better define parameter and return typesconfigureLoggingFromConfig
functionfinaliseLogLevel
, finaliseUseLevelPrefixes
and finaliseUseConsoleTrace
functionsdefaultLogLevel
, defaultUseLevelPrefixes
and defaultUseConsoleTrace
properties & config.json settingslogging-utils
module to logging
module.core-functions
dependency to version 2.0.3core-functions
dependency to version 2.0.2underlyingLogger
and forceConfiguration
arguments to the configureDefaultLogging
functionconfigureLoggingFromConfig
function to simplify configuring from a config object/fileconfigureDefaultLogging
and configureLoggingFromConfig
functionscore-functions
dependency to version 2.0.1core-functions/functions
functions with standard JS functionalitycore-functions
dependency to version 2.0.0configureDefaultLogging
function for clarity.FAQs
Utilities for configuring simple log level based logging functionality on an object
The npm package logging-utils receives a total of 48 weekly downloads. As such, logging-utils popularity was classified as not popular.
We found that logging-utils 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.