Skip to content

Commit 0a3a3d0

Browse files
committed
docs: improve README and add community files
- Enhance README with centered logo, badges, and better structure - Add CONTRIBUTING.md with development guidelines - Add CODE_OF_CONDUCT.md based on Contributor Covenant - Add CHANGELOG.md following Keep a Changelog format
1 parent 2ba04f0 commit 0a3a3d0

File tree

4 files changed

+191
-121
lines changed

4 files changed

+191
-121
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2026-01-13
9+
10+
### Added
11+
12+
- Initial release of LogTide Node.js SDK
13+
- Automatic batching with configurable size and interval
14+
- Retry logic with exponential backoff
15+
- Circuit breaker pattern for fault tolerance
16+
- Max buffer size with drop policy
17+
- Query API for searching and filtering logs
18+
- Live tail with Server-Sent Events (SSE)
19+
- Trace ID context for distributed tracing
20+
- Global metadata support
21+
- Structured error serialization
22+
- Internal metrics tracking
23+
- Logging methods: debug, info, warn, error, critical
24+
- Express middleware for auto-logging HTTP requests
25+
- Fastify plugin for auto-logging HTTP requests
26+
- Full TypeScript support with strict types
27+
- ESM and CommonJS module support
28+
29+
[0.1.0]: https://github.com/logtide-dev/logtide-sdk-node/releases/tag/v0.1.0

CODE_OF_CONDUCT.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
We are committed to providing a welcoming and inclusive environment for everyone, regardless of background or identity.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to a positive environment:
10+
11+
- Being respectful and inclusive
12+
- Accepting constructive criticism gracefully
13+
- Focusing on what is best for the community
14+
- Showing empathy towards others
15+
16+
Examples of unacceptable behavior:
17+
18+
- Harassment, trolling, or insulting comments
19+
- Personal or political attacks
20+
- Publishing others' private information without permission
21+
- Other conduct that would be inappropriate in a professional setting
22+
23+
## Enforcement
24+
25+
Project maintainers have the right to remove, edit, or reject comments, commits, code, issues, and other contributions that are not aligned with this Code of Conduct.
26+
27+
## Reporting
28+
29+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at **[email protected]**.
30+
31+
All complaints will be reviewed and investigated promptly and fairly.
32+
33+
## Attribution
34+
35+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.

CONTRIBUTING.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributing to LogTide Node.js SDK
2+
3+
Thank you for your interest in contributing!
4+
5+
## Development Setup
6+
7+
1. Clone the repository:
8+
```bash
9+
git clone https://github.com/logtide-dev/logtide-sdk-node.git
10+
cd logtide-sdk-node
11+
```
12+
13+
2. Install dependencies:
14+
```bash
15+
pnpm install
16+
```
17+
18+
3. Build the project:
19+
```bash
20+
pnpm build
21+
```
22+
23+
## Code Style
24+
25+
- Follow [TypeScript Best Practices](https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html)
26+
- Use strict TypeScript with no implicit any
27+
- Format code with [Prettier](https://prettier.io/)
28+
- Lint with [ESLint](https://eslint.org/)
29+
- Use meaningful variable and function names
30+
- Add JSDoc comments for public APIs
31+
32+
## Testing
33+
34+
```bash
35+
# Run tests
36+
pnpm test
37+
38+
# Run tests in watch mode
39+
pnpm test:watch
40+
41+
# Run tests with coverage
42+
pnpm test:coverage
43+
44+
# Type checking
45+
pnpm typecheck
46+
47+
# Linting
48+
pnpm lint
49+
50+
# Format code
51+
pnpm format
52+
```
53+
54+
## Pull Request Process
55+
56+
1. Fork the repository
57+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
58+
3. Make your changes
59+
4. Ensure tests pass (`pnpm test`)
60+
5. Lint and format code (`pnpm lint && pnpm format`)
61+
6. Commit your changes (`git commit -m 'Add amazing feature'`)
62+
7. Push to the branch (`git push origin feature/amazing-feature`)
63+
8. Open a Pull Request
64+
65+
## Reporting Issues
66+
67+
- Use the GitHub issue tracker
68+
- Provide clear description and reproduction steps
69+
- Include Node.js version and OS information
70+
- Include relevant logs and error messages
71+
72+
## Questions?
73+
74+
Feel free to open an issue for any questions or discussions!

README.md

Lines changed: 53 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
# LogTide Node.js SDK
1+
<p align="center">
2+
<img src="https://raw.githubusercontent.com/logtide-dev/logtide/main/docs/images/logo.png" alt="LogTide Logo" width="400">
3+
</p>
24

3-
Official Node.js SDK for LogTide with advanced features: retry logic, circuit breaker, query API, live streaming, and middleware support.
5+
<h1 align="center">LogTide Node.js SDK</h1>
6+
7+
<p align="center">
8+
<a href="https://www.npmjs.com/package/@logtide/sdk-node"><img src="https://img.shields.io/npm/v/@logtide/sdk-node?color=blue" alt="npm"></a>
9+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"></a>
10+
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/Node.js-18+-green.svg" alt="Node.js"></a>
11+
<a href="https://github.com/logtide-dev/logtide-sdk-node/releases"><img src="https://img.shields.io/github/v/release/logtide-dev/logtide-sdk-node" alt="Release"></a>
12+
</p>
13+
14+
<p align="center">
15+
Official Node.js SDK for <a href="https://logtide.dev">LogTide</a> with automatic batching, retry logic, circuit breaker, query API, live streaming, and middleware support.
16+
</p>
17+
18+
---
419

520
## Features
621

7-
- **Automatic batching** with configurable size and interval
8-
- **Retry logic** with exponential backoff
9-
- **Circuit breaker** pattern for fault tolerance
10-
- **Max buffer size** with drop policy to prevent memory leaks
11-
- **Query API** for searching and filtering logs
12-
- **Live tail** with Server-Sent Events (SSE)
13-
- **Trace ID context** for distributed tracing
14-
- **Global metadata** added to all logs
15-
- **Structured error serialization**
16-
- **Internal metrics** (logs sent, errors, latency, etc.)
17-
- **Express & Fastify middleware** for auto-logging HTTP requests
18-
- **Full TypeScript support** with strict types
22+
- **Automatic batching** with configurable size and interval
23+
- **Retry logic** with exponential backoff
24+
- **Circuit breaker** pattern for fault tolerance
25+
- **Max buffer size** with drop policy to prevent memory leaks
26+
- **Query API** for searching and filtering logs
27+
- **Live tail** with Server-Sent Events (SSE)
28+
- **Trace ID context** for distributed tracing
29+
- **Global metadata** added to all logs
30+
- **Structured error serialization**
31+
- **Internal metrics** (logs sent, errors, latency, etc.)
32+
- **Express & Fastify middleware** for auto-logging HTTP requests
33+
- **Full TypeScript support** with strict types
1934

2035
## Installation
2136

@@ -89,7 +104,7 @@ const client = new LogTideClient({
89104
// Buffer management
90105
maxBufferSize: 10000,
91106

92-
// Retry with exponential backoff (1s 2s 4s)
107+
// Retry with exponential backoff (1s -> 2s -> 4s)
93108
maxRetries: 3,
94109
retryDelayMs: 1000,
95110

@@ -158,9 +173,9 @@ client.log({
158173
service: 'custom-service',
159174
level: 'info',
160175
message: 'Custom log',
161-
time: new Date().toISOString(), // Optional
176+
time: new Date().toISOString(),
162177
metadata: { key: 'value' },
163-
trace_id: 'custom-trace-id', // Optional
178+
trace_id: 'custom-trace-id',
164179
});
165180
```
166181

@@ -201,16 +216,6 @@ client.withNewTraceId(() => {
201216
});
202217
```
203218

204-
### Auto Trace ID Mode
205-
206-
```typescript
207-
const client = new LogTideClient({
208-
apiUrl: 'http://localhost:8080',
209-
apiKey: 'lp_your_api_key_here',
210-
autoTraceId: true, // Every log gets a unique trace ID
211-
});
212-
```
213-
214219
---
215220

216221
## Query API
@@ -315,7 +320,9 @@ client.resetMetrics();
315320

316321
---
317322

318-
## Middleware
323+
## Middleware Integration
324+
325+
LogTide provides ready-to-use middleware for popular frameworks.
319326

320327
### Express Middleware
321328

@@ -385,6 +392,17 @@ await fastify.listen({ port: 3000 });
385392

386393
---
387394

395+
## Examples
396+
397+
See the [examples/](./examples) directory for complete working examples:
398+
399+
- **[basic.ts](./examples/basic.ts)** - Simple usage
400+
- **[advanced.ts](./examples/advanced.ts)** - All advanced features
401+
- **[express-middleware.ts](./examples/express-middleware.ts)** - Express integration
402+
- **[fastify-plugin.ts](./examples/fastify-plugin.ts)** - Fastify integration
403+
404+
---
405+
388406
## Best Practices
389407

390408
### 1. Always Close on Shutdown
@@ -442,72 +460,6 @@ setInterval(() => {
442460
}, 60000);
443461
```
444462

445-
### 5. Use Trace IDs for Request Correlation
446-
447-
```typescript
448-
app.use((req, res, next) => {
449-
const traceId = req.headers['x-trace-id'] || randomUUID();
450-
req.traceId = traceId;
451-
452-
client.withTraceId(traceId, () => {
453-
next();
454-
});
455-
});
456-
```
457-
458-
---
459-
460-
## API Reference
461-
462-
### LogTideClient
463-
464-
#### Constructor
465-
```typescript
466-
new LogTideClient(options: LogTideClientOptions)
467-
```
468-
469-
#### Logging Methods
470-
- `log(entry: LogEntry): void`
471-
- `debug(service: string, message: string, metadata?: object): void`
472-
- `info(service: string, message: string, metadata?: object): void`
473-
- `warn(service: string, message: string, metadata?: object): void`
474-
- `error(service: string, message: string, metadataOrError?: object | Error): void`
475-
- `critical(service: string, message: string, metadataOrError?: object | Error): void`
476-
477-
#### Context Methods
478-
- `setTraceId(traceId: string | null): void`
479-
- `getTraceId(): string | null`
480-
- `withTraceId<T>(traceId: string, fn: () => T): T`
481-
- `withNewTraceId<T>(fn: () => T): T`
482-
483-
#### Query Methods
484-
- `query(options: QueryOptions): Promise<LogsResponse>`
485-
- `getByTraceId(traceId: string): Promise<InternalLogEntry[]>`
486-
- `getAggregatedStats(options: AggregatedStatsOptions): Promise<AggregatedStatsResponse>`
487-
488-
#### Streaming
489-
- `stream(options: StreamOptions): () => void` (returns cleanup function)
490-
491-
#### Metrics
492-
- `getMetrics(): ClientMetrics`
493-
- `resetMetrics(): void`
494-
- `getCircuitBreakerState(): string`
495-
496-
#### Lifecycle
497-
- `flush(): Promise<void>`
498-
- `close(): Promise<void>`
499-
500-
---
501-
502-
## Examples
503-
504-
See the [examples/](./examples) directory for complete working examples:
505-
506-
- **[basic.ts](./examples/basic.ts)** - Simple usage
507-
- **[advanced.ts](./examples/advanced.ts)** - All advanced features
508-
- **[express-middleware.ts](./examples/express-middleware.ts)** - Express integration
509-
- **[fastify-plugin.ts](./examples/fastify-plugin.ts)** - Fastify integration
510-
511463
---
512464

513465
## TypeScript Support
@@ -526,36 +478,16 @@ import type {
526478

527479
---
528480

529-
## Testing
530-
531-
Run the test suite:
532-
533-
```bash
534-
# Run tests
535-
pnpm test
536-
537-
# Watch mode
538-
pnpm test:watch
539-
540-
# Coverage
541-
pnpm test:coverage
542-
```
481+
## Contributing
543482

544-
---
483+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
545484

546485
## License
547486

548-
MIT
549-
550-
---
551-
552-
## Contributing
553-
554-
Contributions are welcome! Please open an issue or PR on [GitHub](https://github.com/logtide-dev/logtide-sdk-node).
555-
556-
---
487+
MIT License - see [LICENSE](LICENSE) for details.
557488

558-
## Support
489+
## Links
559490

560-
- **Documentation**: [https://logtide.dev/docs](https://logtide.dev/docs)
561-
- **Issues**: [GitHub Issues](https://github.com/logtide-dev/logtide-sdk-node/issues)
491+
- [LogTide Website](https://logtide.dev)
492+
- [Documentation](https://logtide.dev/docs/sdks/node/)
493+
- [GitHub Issues](https://github.com/logtide-dev/logtide-sdk-node/issues)

0 commit comments

Comments
 (0)