quto-logger
v1.0.0
Published
Lightweight error and event logging SDK for Quto.dev — a simple Sentry alternative
Maintainers
Readme
quto-logger
Lightweight error and event logging SDK for Quto.dev — a simple Sentry alternative.
Install
npm install quto-loggerQuick Start
import QutoLogger from 'quto-logger';
const logger = new QutoLogger({
apiKey: 'your-api-key-here',
environment: 'production', // optional: 'production' | 'staging' | 'development'
});
// Log an error
await logger.error('Payment processing failed', { userId: '123', orderId: 'abc' });
// Log a warning
await logger.warning('API response slow', { endpoint: '/api/users', latency: 2500 });
// Log info
await logger.info('User signed up', { plan: 'pro' });
// Capture exceptions with stack traces
try {
await riskyOperation();
} catch (err) {
await logger.captureException(err, { context: 'checkout-flow' });
}Getting Your API Key
- Go to quto.dev/tools/error-logging
- Create an account and log in
- Click "New Application" and give it a name
- Copy the API key from the applications table
API
new QutoLogger(options)
| Option | Type | Required | Default | Description |
|--------|------|----------|---------|-------------|
| apiKey | string | Yes | — | Your Quto application API key |
| environment | string | No | 'production' | Environment name |
| baseUrl | string | No | 'https://api.quto.dev' | API base URL |
| debug | boolean | No | false | Log send failures to console |
Methods
| Method | Description |
|--------|-------------|
| logger.error(message, metadata?) | Log an error |
| logger.warning(message, metadata?) | Log a warning |
| logger.info(message, metadata?) | Log an info event |
| logger.captureException(error, metadata?) | Capture an Error object with stack trace |
All methods return Promise<{ success: boolean, log_id: number } | null>. Returns null on failure (never throws).
Metadata
Pass any object as metadata to attach context to your logs:
await logger.error('Database connection failed', {
host: 'db.example.com',
retryCount: 3,
lastError: 'ECONNREFUSED',
});REST API (without SDK)
You can also send logs directly via HTTP:
curl -X POST https://api.quto.dev/api/logs \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key-here" \
-d '{
"level": "error",
"message": "Something went wrong",
"stack": "Error: Something went wrong\n at main (app.js:10)",
"environment": "production",
"metadata": { "userId": "123" }
}'Request Body
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| level | string | Yes | 'error', 'warning', or 'info' |
| message | string | Yes | Log message (max 5000 chars) |
| stack | string | No | Stack trace (max 10000 chars) |
| environment | string | No | 'production', 'staging', or 'development' |
| metadata | object | No | Any additional context |
Frameworks
Express.js
import QutoLogger from 'quto-logger';
const logger = new QutoLogger({ apiKey: process.env.QUTO_API_KEY });
app.use((err, req, res, next) => {
logger.captureException(err, {
method: req.method,
url: req.originalUrl,
ip: req.ip,
});
res.status(500).json({ error: 'Internal server error' });
});React
import QutoLogger from 'quto-logger';
const logger = new QutoLogger({
apiKey: 'your-api-key',
environment: process.env.NODE_ENV,
});
// Global error handler
window.addEventListener('error', (event) => {
logger.captureException(event.error, { url: window.location.href });
});
window.addEventListener('unhandledrejection', (event) => {
logger.error('Unhandled promise rejection', {
reason: String(event.reason),
url: window.location.href,
});
});Node.js
import QutoLogger from 'quto-logger';
const logger = new QutoLogger({ apiKey: process.env.QUTO_API_KEY });
process.on('uncaughtException', (err) => {
logger.captureException(err).then(() => process.exit(1));
});
process.on('unhandledRejection', (reason) => {
logger.error('Unhandled rejection', { reason: String(reason) });
});License
MIT
