New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gasket/plugin-logger

Package Overview
Dependencies
Maintainers
8
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gasket/plugin-logger - npm Package Compare versions

Comparing version 7.2.0-canary.20 to 7.2.0

lib/utils.js

36

lib/index.d.ts

@@ -1,14 +0,28 @@

import type { MaybeAsync } from '@gasket/core';
import type { MaybeAsync, Plugin, Hook, HookId } from '@gasket/core';
import type { Logger } from '@gasket/plugin-logger';
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type LogMethods = Record<LogLevel, (...args: any[]) => void>;
type LogMethods = Record<LogLevel, (...args: any[]) => void>;
export function createChildLogger(
parent: {
[K in HookId]?: Hook<K>;
},
metadata: Record<string, any>
): Logger;
export type Logger = LogMethods & {
export function verifyLoggerLevels(logger: Logger): void;
declare module '@gasket/plugin-logger' {
export interface Logger extends LogMethods {
close?: () => MaybeAsync<any>;
child: (meta: Record<string, any>) => Logger;
};
}
}
declare module '@gasket/core' {
import { Logger } from '@gasket/plugin-logger';
interface Gasket {

@@ -19,11 +33,15 @@ logger: Logger;

export interface HookExecTypes {
createLogger(): Logger
createLogger(): Logger;
}
export interface GasketActions {
getLogger(): Logger;
}
}
export default {
const plugin: Plugin = {
name: '@gasket/plugin-logger',
version: '',
description: '',
hooks: {}
};
export = plugin;

@@ -0,27 +1,17 @@

/// <reference types="create-gasket-app" />
/// <reference types="@gasket/plugin-https" />
/// <reference types="@gasket/plugin-metadata" />
/* eslint-disable no-console, no-sync */
const { name, version, description } = require('../package.json');
const { createChildLogger, verifyLoggerLevels } = require('./utils');
function createChildLogger(parent, metadata) {
return {
...parent,
debug: (...args) => console.debug(...args, metadata),
error: (...args) => console.error(...args, metadata),
info: (...args) => console.info(...args, metadata),
warn: (...args) => console.warn(...args, metadata),
child: (meta) => createChildLogger(this, { ...metadata, ...meta })
};
}
function verifyLoggerLevels(logger) {
['debug', 'error', 'info', 'warn', 'child'].forEach((level) => {
if (typeof logger[level] !== 'function') {
throw new Error(`Logger is missing required level: ${level}`);
}
});
}
module.exports = {
/** @type {import('@gasket/core').Plugin} */
const plugin = {
name,
version,
description,
actions: {
getLogger: (gasket) => gasket.logger
},
hooks: {

@@ -35,6 +25,8 @@ create(gasket, { pkg, gasketConfig }) {

init(gasket) {
// eslint-disable-next-line no-sync
const loggers = gasket.execSync('createLogger');
if (loggers && loggers.some((logger) => logger && logger instanceof Promise)) {
if (
loggers &&
loggers.some((logger) => logger && logger instanceof Promise)
) {
throw new Error('createLogger hooks must be synchronous');

@@ -60,7 +52,2 @@ }

},
actions(gasket) {
return {
getLogger: () => gasket.logger
};
},
async onSignal(gasket) {

@@ -72,2 +59,9 @@ await gasket.logger?.close?.();

...meta,
actions: [
{
name: 'getLogger',
description: 'Get the logger instance',
link: 'README.md#getLogger'
}
],
lifecycles: [

@@ -86,1 +80,3 @@ {

};
module.exports = plugin;
{
"name": "@gasket/plugin-logger",
"version": "7.2.0-canary.20",
"version": "7.2.0",
"description": "Gasket plugin for logging",

@@ -16,3 +16,5 @@ "main": "lib/index.js",

"test:coverage": "jest --coverage",
"posttest": "npm run lint"
"posttest": "npm run lint",
"typecheck:watch": "tsc --watch",
"typecheck:skip": "tsc"
},

@@ -38,11 +40,13 @@ "repository": {

"devDependencies": {
"@gasket/core": "^7.2.0-canary.20",
"@gasket/plugin-https": "^7.2.0-canary.20",
"@gasket/plugin-metadata": "^7.2.0-canary.20",
"@gasket/core": "^7.2.0",
"@gasket/plugin-https": "^7.2.0",
"@gasket/plugin-metadata": "^7.2.0",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-godaddy": "^7.1.0",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-unicorn": "^44.0.0",
"jest": "^29.7.0"
"eslint-config-godaddy": "^7.1.1",
"eslint-config-godaddy-typescript": "^4.0.3",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-unicorn": "^55.0.0",
"jest": "^29.7.0",
"typescript": "^5.4.5"
},

@@ -52,12 +56,24 @@ "eslintConfig": {

"godaddy",
"plugin:jest/recommended"
"plugin:jest/recommended",
"plugin:jsdoc/recommended-typescript-flavor"
],
"plugins": [
"unicorn"
"unicorn",
"jsdoc"
],
"rules": {
"unicorn/filename-case": "error"
}
},
"overrides": [
{
"files": [
"*.ts"
],
"extends": [
"godaddy-typescript"
]
}
]
},
"gitHead": "abdb788c7ff44f4c6db7a5885e96e2dd315273fc"
"gitHead": "8790fd065f4bcb853fc9a2deecf0833999f41443"
}

@@ -10,2 +10,16 @@ # @gasket/plugin-logger

## Installation
This plugin is only used by presets for `create-gasket-app` and is not installed for apps.
## Actions
### getLogger
Get the logger instance using the Actions API.
```js
const logger = gasket.actions.getLogger();
```
## Lifecycles

@@ -12,0 +26,0 @@

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