샘플
debug 4.3.7: disable, enable, enabled
검증된 샘플 — npm debug 4.3.7: disable, enable, enabled. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: debug creates a debugger instance with the…
sha256:b72d04f00b87eba6bc94ce589fa73383c12ad9aa0ef44a50fa7adae590abd289
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
케이스
HOW- 목표
- verify pkg:npm/debug@4.3.7
- 패키지
- 심벌
-
- debug
- debug.disable
- debug.enable
- debug.enabled
- debug.extend
- 생성일
- 2026-08-27T12:46:48Z
컨트랙트
- debug creates a debugger instance with the given namespace property and enabled status
- debug.enable activates namespaces matching pattern and updates existing debug instance enabled property
- debug.disable deactivates all namespaces and returns previous namespaces string
- debug.enabled checks whether a namespace string matches current enabled configuration including wildcard and negation prefix
- debug.extend creates a child debugger with namespace appended using default colon delimiter
- debug.extend supports custom delimiter when creating extended child debugger
- debug executes custom log function only when enabled and forwards namespace prefix and arguments
- debug does not invoke log function when namespace is disabled
- debug supports registering custom formatter functions in debug.formatters
- configureLogging helper enables specified namespaces and updates debug instance state
파일
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/debug@4.3.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/debug@4.3.7
Demonstrate these symbols/APIs:
- debug
- debug.disable
- debug.enable
- debug.enabled
- debug.extend
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:5af7d7e45500c1bc128b64f22323d39f9dac87cd77d0e8388954fe74317fcde1","contract":["debug creates a debugger instance with the given namespace property and enabled status","debug.enable activates namespaces matching pattern and updates existing debug instance enabled property","debug.disable deactivates all namespaces and returns previous namespaces string","debug.enabled checks whether a namespace string matches current enabled configuration including wildcard and negation prefix","debug.extend creates a child debugger with namespace appended using default colon delimiter","debug.extend supports custom delimiter when creating extended child debugger","debug executes custom log function only when enabled and forwards namespace prefix and arguments","debug does not invoke log function when namespace is disabled","debug supports registering custom formatter functions in debug.formatters","configureLogging helper enables specified namespaces and updates debug instance state"],"goal":"verify pkg:npm/debug@4.3.7","kind":"HOW","packages":["pkg:npm/debug@4.3.7"],"schemaVersion":1,"symbols":["debug","debug.disable","debug.enable","debug.enabled","debug.extend"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/debug@4.3.7"],"schemaVersion":1,"subject":"pkg:npm/debug@4.3.7","symbols":["debug","debug.disable","debug.enable","debug.enabled","debug.extend"],"verifierAdapter":"node-typescript@1"}
import debug from 'debug';
/**
* Creates a scoped logger with an optional sub-namespace extension.
*
* @param {string} namespace - The root namespace for the debugger.
* @returns {Function} A configured debug instance.
*/
export function createLogger(namespace) {
return debug(namespace);
}
/**
* Creates a child logger extended from a parent logger instance.
*
* @param {Function} parentLogger - The parent debug instance.
* @param {string} subNamespace - The sub-namespace to append.
* @param {string} [delimiter] - Optional delimiter (defaults to ':').
* @returns {Function} An extended child debug instance.
*/
export function extendLogger(parentLogger, subNamespace, delimiter) {
if (delimiter !== undefined) {
return parentLogger.extend(subNamespace, delimiter);
}
return parentLogger.extend(subNamespace);
}
/**
* Configures global debug namespace filters.
*
* @param {string} namespaces - Space- or comma-delimited list of namespace patterns to enable.
*/
export function configureLogging(namespaces) {
debug.enable(namespaces);
}
export default debug;
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"debug": "4.3.7"
}
},
"node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"debug": "4.3.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/debug@4.3.7",
"kind": "HOW",
"packages": [
"pkg:npm/debug@4.3.7"
],
"symbols": [
"debug",
"debug.disable",
"debug.enable",
"debug.enabled",
"debug.extend"
]
}
import assert from 'node:assert/strict';
import debug from 'debug';
import { createLogger, extendLogger, configureLogging } from '../index.mjs';
// Clean state before running tests
debug.disable();
// Case 1: debug creates a debugger instance with the given namespace property and enabled status
{
const log = debug('app:server');
assert.equal(typeof log, 'function', 'debug() should return a function');
assert.equal(log.namespace, 'app:server', 'debugger should store its namespace');
assert.equal(log.enabled, false, 'debugger should default to disabled when no namespaces are enabled');
const helperLog = createLogger('app:worker');
assert.equal(helperLog.namespace, 'app:worker', 'createLogger helper should return debug instance with namespace');
}
// Case 2: debug.enable activates namespaces matching pattern and updates existing debug instance enabled property
{
const serverLog = debug('app:server');
const dbLog = debug('db:query');
assert.equal(serverLog.enabled, false, 'serverLog initially disabled');
assert.equal(dbLog.enabled, false, 'dbLog initially disabled');
debug.enable('app:*');
assert.equal(serverLog.enabled, true, 'serverLog enabled after debug.enable("app:*")');
assert.equal(dbLog.enabled, false, 'dbLog remains disabled when not matching "app:*"');
}
// Case 3: debug.disable deactivates all namespaces and returns previous namespaces string
{
debug.enable('app:*,db:*');
const prev = debug.disable();
assert.equal(prev, 'app:*,db:*', 'debug.disable() should return previous enabled namespaces pattern');
const log = debug('app:server');
assert.equal(log.enabled, false, 'debugger should be disabled after debug.disable()');
}
// Case 4: debug.enabled checks whether a namespace string matches current enabled configuration including wildcard and negation prefix
{
debug.enable('app:*,-app:secret');
assert.equal(debug.enabled('app:server'), true, 'debug.enabled should return true for matched namespace');
assert.equal(debug.enabled('db:client'), false, 'debug.enabled should return false for unmatched namespace');
assert.equal(debug.enabled('app:secret'), false, 'debug.enabled should return false for excluded namespace with negation prefix -');
}
// Case 5: debug.extend creates a child debugger with namespace appended using default colon delimiter
{
debug.enable('app:*');
const rootLog = debug('app');
const childLog = rootLog.extend('http');
assert.equal(typeof childLog, 'function', 'extend() should return a function');
assert.equal(childLog.namespace, 'app:http', 'extended namespace should append with default colon delimiter');
assert.equal(childLog.enabled, true, 'extended debugger should be enabled matching pattern');
const helperChild = extendLogger(rootLog, 'events');
assert.equal(helperChild.namespace, 'app:events', 'extendLogger helper should extend with default delimiter');
}
// Case 6: debug.extend supports custom delimiter when creating extended child debugger
{
const rootLog = debug('worker');
const childLog = rootLog.extend('job1', '/');
assert.equal(childLog.namespace, 'worker/job1', 'extended namespace should use specified custom delimiter');
const helperCustom = extendLogger(rootLog, 'job2', '#');
assert.equal(helperCustom.namespace, 'worker#job2', 'extendLogger helper should support custom delimiter');
}
// Case 7: debug executes custom log function only when enabled and forwards namespace prefix and arguments
{
debug.enable('test:handler');
const log = debug('test:handler');
const calls = [];
log.log = (...args) => {
calls.push(args);
};
log('request received', 200);
assert.equal(calls.length, 1, 'custom log handler should be invoked when enabled');
assert.equal(calls[0].length, 2, 'custom log handler receives prefix string and additional arg');
assert.ok(calls[0][0].includes('test:handler request received'), 'first argument contains formatted prefix and string');
assert.equal(calls[0][1], 200, 'second argument passed through');
}
// Case 8: debug does not invoke log function when namespace is disabled
{
debug.disable();
const log = debug('test:disabled');
let invoked = false;
log.log = () => {
invoked = true;
};
log('this message should not be logged');
assert.equal(invoked, false, 'log handler should not be called when debugger is disabled');
}
// Case 9: debug supports registering custom formatter functions in debug.formatters
{
debug.formatters.u = (val) => String(val).toUpperCase();
debug.enable('test:custom-fmt');
const log = debug('test:custom-fmt');
const calls = [];
log.log = (...args) => {
calls.push(args);
};
log('greeting: %u', 'hello');
assert.equal(calls.length, 1, 'log handler called');
assert.ok(calls[0][0].includes('greeting: HELLO'), 'custom formatter %u should uppercase input in output string');
delete debug.formatters.u;
}
// Case 10: configureLogging helper enables specified namespaces and updates debug instance state
{
configureLogging('service:api');
const apiLog = debug('service:api');
const otherLog = debug('service:db');
assert.equal(apiLog.enabled, true, 'apiLog should be enabled after configureLogging');
assert.equal(otherLog.enabled, false, 'otherLog should be disabled after configureLogging');
}
// Reset state
debug.disable();
console.log('PASS: all debug contract assertions passed');
오리진 시더
익명