You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@peerbit/logger

Package Overview
Dependencies
Maintainers
1
Versions
299
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerbit/logger - npm Package Compare versions

Comparing version
1.0.4
to
2.0.0-1929680
+1
-14
dist/src/index.d.ts

@@ -1,15 +0,2 @@

type LogLevel = "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent";
/**
* Safely read an env var from:
* - Node: process.env
* - Webpack/CRA (browser/worker): globalThis.process.env (if defined by bundler)
* - Vite (browser/worker): import.meta.env
*/
export declare const getEnv: (key: string) => string | undefined;
export declare const getLogLevel: () => LogLevel | undefined;
declare const logger: (options?: {
module?: string;
level?: LogLevel;
}) => import("pino").Logger<never>;
export { logger };
export * from "@libp2p/logger";
//# sourceMappingURL=index.d.ts.map
+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,KAAK,QAAQ,GACV,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAyB7C,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,QAAQ,GAAG,SAmBzC,CAAC;AAEF,QAAA,MAAM,MAAM,GAAI,UAAU;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,iCAc9D,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}

@@ -1,65 +0,2 @@

import pino from "pino";
// Robust Node detection (true only in Node.js)
const isNode = typeof process !== "undefined" && !!process.versions?.node;
/**
* Safely read an env var from:
* - Node: process.env
* - Webpack/CRA (browser/worker): globalThis.process.env (if defined by bundler)
* - Vite (browser/worker): import.meta.env
*/
export const getEnv = (key) => {
if (isNode) {
return process.env?.[key];
}
// Some bundlers (Webpack/CRA) inject a process shim
const g = typeof globalThis !== "undefined" ? globalThis : {};
if (g.process?.env && typeof g.process.env[key] !== "undefined") {
return g.process.env[key];
}
// Vite exposes import.meta.env
let metaEnv;
try {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - import.meta may not exist in TS/node type context
metaEnv = import.meta?.env;
}
catch {
// ignore if not supported
}
if (metaEnv && typeof metaEnv[key] !== "undefined") {
return metaEnv[key];
}
return undefined;
};
export const getLogLevel = () => {
const level = getEnv("LOG_LEVEL") || getEnv("REACT_APP_LOG_LEVEL");
if (!level)
return undefined;
const levels = [
"fatal",
"error",
"warn",
"info",
"debug",
"trace",
"silent",
];
if (!levels.includes(level)) {
throw new Error(`Unexpected LOG_LEVEL: ${level}. Expecting one of: ${JSON.stringify(levels)}`);
}
return level;
};
const logger = (options) => {
// In browsers/workers, pino's browser build logs to console by default.
let base = pino();
if (options?.module) {
base = base.child({ module: options.module });
}
const level = options?.level ?? getLogLevel();
if (level) {
base.level = level;
}
return base;
};
export { logger };
export * from "@libp2p/logger";
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,+CAA+C;AAC/C,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;AAW1E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,G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C;AAC1B,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,OAA+C,EAAE,EAAE;IAClE,wEAAwE;IACxE,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;IAElB,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACrB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,CAAC;IAC9C,IAAI,KAAK,EAAE,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
{
"name": "@peerbit/logger",
"version": "1.0.4",
"description": "Logging utils",
"sideEffects": false,
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},
"eslintConfig": {
"extends": "peerbit",
"parserOptions": {
"project": true,
"sourceType": "module"
},
"ignorePatterns": [
"!.aegir.js",
"test/ts-use",
"*.d.ts"
]
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"pino": "^8.14.1"
},
"scripts": {
"clean": "aegir clean",
"build": "aegir build --no-bundle",
"test": "aegir test --target node",
"lint": "aegir lint"
},
"author": "dao.xyz",
"license": "MIT"
}
"name": "@peerbit/logger",
"version": "2.0.0-1929680",
"description": "Logging utils",
"sideEffects": false,
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},
"eslintConfig": {
"extends": "peerbit",
"parserOptions": {
"project": true,
"sourceType": "module"
},
"ignorePatterns": [
"!.aegir.js",
"test/ts-use",
"*.d.ts"
]
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@libp2p/logger": "^6.2.1"
},
"author": "dao.xyz",
"license": "MIT",
"scripts": {
"clean": "aegir clean",
"build": "aegir build --no-bundle",
"test": "aegir test --target node",
"lint": "aegir lint"
}
}

@@ -1,85 +0,1 @@

import pino from "pino";
// Robust Node detection (true only in Node.js)
const isNode = typeof process !== "undefined" && !!process.versions?.node;
type LogLevel =
| "fatal"
| "error"
| "warn"
| "info"
| "debug"
| "trace"
| "silent";
/**
* Safely read an env var from:
* - Node: process.env
* - Webpack/CRA (browser/worker): globalThis.process.env (if defined by bundler)
* - Vite (browser/worker): import.meta.env
*/
export const getEnv = (key: string): string | undefined => {
if (isNode) {
return process.env?.[key];
}
// Some bundlers (Webpack/CRA) inject a process shim
const g: any = typeof globalThis !== "undefined" ? (globalThis as any) : {};
if (g.process?.env && typeof g.process.env[key] !== "undefined") {
return g.process.env[key];
}
// Vite exposes import.meta.env
let metaEnv: any;
try {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - import.meta may not exist in TS/node type context
metaEnv = import.meta?.env;
} catch {
// ignore if not supported
}
if (metaEnv && typeof metaEnv[key] !== "undefined") {
return metaEnv[key];
}
return undefined;
};
export const getLogLevel = (): LogLevel | undefined => {
const level = getEnv("LOG_LEVEL") || getEnv("REACT_APP_LOG_LEVEL");
if (!level) return undefined;
const levels: LogLevel[] = [
"fatal",
"error",
"warn",
"info",
"debug",
"trace",
"silent",
];
if (!levels.includes(level as LogLevel)) {
throw new Error(
`Unexpected LOG_LEVEL: ${level}. Expecting one of: ${JSON.stringify(levels)}`,
);
}
return level as LogLevel;
};
const logger = (options?: { module?: string; level?: LogLevel }) => {
// In browsers/workers, pino's browser build logs to console by default.
let base = pino();
if (options?.module) {
base = base.child({ module: options.module });
}
const level = options?.level ?? getLogLevel();
if (level) {
base.level = level;
}
return base;
};
export { logger };
export * from "@libp2p/logger";