craig-o-logs-sdk
v1.0.0
Published
Official SDK for Craig-O-Logs - Modern log aggregation service
Maintainers
Readme
@craig-o-logs/sdk
Official SDK for Craig-O-Logs - Modern log aggregation service.
Installation
npm install @craig-o-logs/sdkQuick Start
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();Configuration
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)
});Log Levels
trace- Detailed debugging informationdebug- Debug-level messagesinfo- Informational messageswarn- Warning conditionserror- Error conditionsfatal- Critical errors
Metadata
Attach any metadata to your logs:
logger.info('Order placed', {
orderId: 'ord_123',
customerId: 'cust_456',
amount: 99.99,
items: ['SKU001', 'SKU002'],
});Batching
Logs are automatically batched and sent in groups for efficiency. The SDK will:
- Send logs when
batchSizeis reached - Automatically flush every
flushIntervalmilliseconds - Flush remaining logs when
destroy()is called
License
MIT © VibeCaaS
