Socket
Socket
Sign inDemoInstall

@apify/log

Package Overview
Dependencies
Maintainers
9
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apify/log - npm Package Compare versions

Comparing version 2.2.8 to 2.2.9

65

index.js

@@ -22,2 +22,6 @@ "use strict";

var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,

@@ -101,2 +105,3 @@ mod

}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_log(level, message, data, exception, opts = {}) {

@@ -144,3 +149,3 @@ throw new Error("log() method must be implemented!");

if (!this.options.skipTime) {
maybeDate = `${new Date().toISOString().replace("Z", "").replace("T", " ")} `;
maybeDate = `${(/* @__PURE__ */ new Date()).toISOString().replace("Z", "").replace("T", " ")} `;
}

@@ -266,3 +271,3 @@ const errStack = exception ? this._parseException(exception) : "";

const rec = {
time: !this.options.skipTime ? new Date() : void 0,
time: !this.options.skipTime ? /* @__PURE__ */ new Date() : void 0,
level: this.options.skipLevelInfo && level === 4 /* INFO */ ? void 0 : LogLevel[level],

@@ -300,2 +305,6 @@ msg: message,

constructor(options = {}) {
/**
* Map of available log levels that's useful for easy setting of appropriate log levels.
* Each log level is represented internally by a number. Eg. `log.LEVELS.DEBUG === 5`.
*/
this.LEVELS = LogLevel;

@@ -322,5 +331,21 @@ this.warningsOnceLogged = /* @__PURE__ */ new Set();

}
/**
* Returns the currently selected logging level. This is useful for checking whether a message
* will actually be printed to the console before one actually performs a resource intensive operation
* to construct the message, such as querying a DB for some metadata that need to be added. If the log
* level is not high enough at the moment, it doesn't make sense to execute the query.
*/
getLevel() {
return this.options.level;
}
/**
* Sets the log level to the given value, preventing messages from less important log levels
* from being printed to the console. Use in conjunction with the `log.LEVELS` constants such as
*
* ```
* log.setLevel(log.LEVELS.DEBUG);
* ```
*
* Default log level is INFO.
*/
setLevel(level) {

@@ -342,8 +367,17 @@ if (!LogLevel[level])

}
/**
* Configures logger.
*/
setOptions(options) {
this.options = { ...this.options, ...options };
}
/**
* Returns the logger configuration.
*/
getOptions() {
return { ...this.options };
}
/**
* Creates a new instance of logger that inherits settings from a parent logger.
*/
child(options) {

@@ -363,5 +397,13 @@ let { prefix } = this.options;

}
/**
* Logs an `ERROR` message. Use this method to log error messages that are not directly connected
* to an exception. For logging exceptions, use the `log.exception` method.
*/
error(message, data) {
this.internal(1 /* ERROR */, message, data);
}
/**
* Logs an `ERROR` level message with a nicely formatted exception. Note that the exception is the first parameter
* here and an additional message is only optional.
*/
exception(exception, message, data) {

@@ -373,8 +415,21 @@ this.internal(1 /* ERROR */, message, data, exception);

}
/**
* Logs a `WARNING` level message. Data are stringified and appended to the message.
*/
warning(message, data) {
this.internal(3 /* WARNING */, message, data);
}
/**
* Logs an `INFO` message. `INFO` is the default log level so info messages will be always logged,
* unless the log level is changed. Data are stringified and appended to the message.
*/
info(message, data) {
this.internal(4 /* INFO */, message, data);
}
/**
* Logs a `DEBUG` message. By default, it will not be written to the console. To see `DEBUG`
* messages in the console, set the log level to `DEBUG` either using the `log.setLevel(log.LEVELS.DEBUG)`
* method or using the environment variable `APIFY_LOG_LEVEL=DEBUG`. Data are stringified and appended
* to the message.
*/
debug(message, data) {

@@ -386,2 +441,5 @@ this.internal(5 /* DEBUG */, message, data);

}
/**
* Logs a `WARNING` level message only once.
*/
warningOnce(message) {

@@ -393,2 +451,5 @@ if (this.warningsOnceLogged.has(message))

}
/**
* Logs given message only once as WARNING. It's used to warn user that some feature he is using has been deprecated.
*/
deprecated(message) {

@@ -395,0 +456,0 @@ this.warningOnce(message);

6

package.json
{
"name": "@apify/log",
"version": "2.2.8",
"version": "2.2.9",
"description": "Tools and constants shared across Apify projects.",

@@ -46,6 +46,6 @@ "main": "./index.js",

"dependencies": {
"@apify/consts": "^2.11.0",
"@apify/consts": "^2.12.0",
"ansi-colors": "^4.1.1"
},
"gitHead": "de15d3f81a1a57fb32ea2e84ba751d56db21f923"
"gitHead": "628f113c33df5d2e036540d8f1c8fd8d6f7f8f60"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc