Initial commit: CraftDock as of 2026-11-01

The previous GitHub history was lost with the account (the local .git was missing
its refs and most objects), so this repository starts from the existing code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-01 22:44:39 -03:00
commit 640e52c0c9
99 files changed
+12115

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
import { describe, it, expect } from 'vitest';
import { createLogger } from '../src/logger.js';
describe('logger', () => {
it('formats text logs with timestamp, level, component and message', () => {
let output = '';
const stream = {
write: (data) => { output += data; },
};
const log = createLogger('test-comp', { level: 'info', format: 'text', stream });
log.info('hello world', { foo: 'bar' });
expect(output).toContain('[INFO ] [test-comp] hello world {"foo":"bar"}');
});
it('formats JSON logs when format is json', () => {
let output = '';
const stream = {
write: (data) => { output += data; },
};
const log = createLogger('json-comp', { level: 'info', format: 'json', stream });
log.info('json message', { count: 42 });
const parsed = JSON.parse(output.trim());
expect(parsed.component).toBe('json-comp');
expect(parsed.level).toBe('info');
expect(parsed.msg).toBe('json message');
expect(parsed.meta).toEqual({ count: 42 });
});
it('filters out logs above threshold level', () => {
let output = '';
const stream = {
write: (data) => { output += data; },
};
const log = createLogger('threshold-comp', { level: 'warn', format: 'text', stream });
log.info('should be ignored');
log.warn('should be logged');
expect(output).not.toContain('should be ignored');
expect(output).toContain('should be logged');
});
it('serializes Error objects correctly', () => {
let output = '';
const stream = {
write: (data) => { output += data; },
};
const log = createLogger('error-comp', { level: 'error', format: 'json', stream });
const err = new Error('something went wrong');
log.error('failure', { err });
const parsed = JSON.parse(output.trim());
expect(parsed.meta.err.error).toBe('something went wrong');
expect(parsed.meta.err.stack).toBeDefined();
});
});