Official SDK for Craig-O-Logs - Modern log aggregation service
npm install craig-o-logs-sdkOfficial SDK for Craig-O-Logs - Modern log aggregation service.
``bash`
npm install @craig-o-logs/sdk
`typescript
import { CraigOLogs } from '@craig-o-logs/sdk';
const logger = new CraigOLogs({
apiKey: 'col_your_api_key',
source: 'my-api-server',
});
// Send logs
logger.info('User signed up', { userId: '123' });
logger.error('Payment failed', { orderId: 'abc', error: 'Card declined' });
logger.warn('Rate limit approaching', { current: 95, limit: 100 });
// Immediate send (bypasses batching)
await logger.immediate('fatal', 'Critical system failure');
// Clean up when done
logger.destroy();
`
`typescript`
const logger = new CraigOLogs({
apiKey: 'col_your_api_key', // Required: Your API key
endpoint: 'https://...', // Optional: Custom endpoint
source: 'my-service', // Optional: Default source for all logs
batchSize: 100, // Optional: Max logs before auto-flush (default: 100)
flushInterval: 5000, // Optional: Flush interval in ms (default: 5000)
});
- trace - Detailed debugging informationdebug
- - Debug-level messagesinfo
- - Informational messageswarn
- - Warning conditionserror
- - Error conditionsfatal
- - Critical errors
Attach any metadata to your logs:
`typescript`
logger.info('Order placed', {
orderId: 'ord_123',
customerId: 'cust_456',
amount: 99.99,
items: ['SKU001', 'SKU002'],
});
Logs are automatically batched and sent in groups for efficiency. The SDK will:
- Send logs when batchSize is reachedflushInterval
- Automatically flush every millisecondsdestroy()` is called
- Flush remaining logs when
MIT © VibeCaaS