First off, thank you for considering contributing to Universal Logger! It's people like you that make this project better for everyone.
- Code of Conduct
- How Can I Contribute?
- Development Setup
- Pull Request Process
- Coding Standards
- Commit Messages
- Testing
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
Before creating bug reports, please check the existing issues to avoid duplicates.
When reporting a bug, include:
- Clear and descriptive title
- Steps to reproduce the issue
- Expected behavior vs actual behavior
- Your environment (OS, Node.js version, database version)
- Code samples or error messages
Enhancement suggestions are tracked as GitHub issues.
When suggesting an enhancement, include:
- Clear and descriptive title
- Detailed description of the proposed functionality
- Use cases and examples
- Why this enhancement would be useful
Unsure where to begin? Look for issues labeled:
good first issue- Simple issues perfect for beginnershelp wanted- Issues where we need helpdocumentation- Improvements to documentation
- Node.js 18+
- npm or yarn or pnpm
- Git
# Fork the repository on GitHub
# Clone your fork
git clone https://github.com/YOUR_USERNAME/universal-logger.git
cd universal-logger
# Add upstream remote
git remote add upstream https://github.com/Jordane9999/universal-logger.git
# Install dependencies
npm install
# Build the project
npm run builduniversal-logger/
├── src/ # Source TypeScript files
│ ├── core/ # Core logger implementation
│ ├── adapters/ # Database adapters
│ └── types/ # TypeScript type definitions
├── dist/ # Compiled JavaScript (generated, not committed)
├── examples/ # Usage examples
└── tests/ # Test files (to be added)
Important: Never commit the dist/ folder - it's generated by npm run build
npm run build # Compile TypeScript to JavaScript
npm run dev # Watch mode for development
npm test # Run tests (when implemented)-
Create a new branch from
main:git checkout main git pull upstream main git checkout -b feature/your-feature-name
-
Make your changes following our coding standards
-
Test your changes:
npm run build # Ensure it compiles npm test # Run tests (when available)
-
Update documentation if needed (README.md, JSDoc comments)
-
Commit your changes following our commit message conventions
-
Push to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub
-
Fill out the PR template completely
-
Wait for review - A maintainer will review your PR
- ✅ All tests pass
- ✅ Code follows style guidelines
- ✅ Documentation is updated
- ✅ Commit messages follow conventions
- ✅ No merge conflicts
- ✅ Branch is up-to-date with
main
- At least one maintainer must approve
- All CI checks must pass
- No unresolved conversations
- Branch must be up-to-date with main
Note: The main branch is protected. You cannot push directly to it.
// ✅ Good
export class MongoDBAdapter implements LogAdapter {
private client: MongoClient | null = null;
async connect(): Promise<void> {
// Implementation
}
}
// ❌ Bad - Missing types
export class MongoDBAdapter {
private client;
async connect() {
// Implementation
}
}- Classes: PascalCase (
MongoDBAdapter,UniversalLogger) - Functions: camelCase (
createLogger,sanitizeContext) - Constants: UPPER_SNAKE_CASE (
DEFAULT_SENSITIVE_PATTERNS) - Interfaces: PascalCase with 'I' prefix optional (
LogAdapter,LoggerConfig) - Files: kebab-case for general files, PascalCase for classes (
logger.ts,mongodb.ts)
/**
* Brief description of the function/class
*
* @param config - Configuration object
* @returns Logger instance
* @example
* ```typescript
* const logger = createLogger({ adapter, service: 'api' });
* ```
*/
export function createLogger(config: LoggerConfig): UniversalLogger {
return new UniversalLogger(config);
}// 1. Node.js built-in modules
import { randomUUID } from "crypto";
// 2. External dependencies
import { MongoClient } from "mongodb";
// 3. Internal modules
import { LogAdapter, LogEntry } from "../types/index.js";We follow the Conventional Commits specification.
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code style changes (formatting, semicolons, etc.)refactor: Code change that neither fixes a bug nor adds a featureperf: Performance improvementtest: Adding or updating testschore: Maintenance tasks
# Good examples
feat(mongodb): add TTL index support
fix(logger): sanitize nested objects correctly
docs(readme): update installation instructions
refactor(adapters): simplify connection handling
# Bad examples
update stuff
fixed bug
WIP
asdfasdffeat(postgresql): add connection pooling
Implement connection pooling for PostgreSQL adapter to improve
performance and resource management.
- Add poolSize option to PostgreSQLAdapterConfig
- Reuse connections instead of creating new ones
- Add connection cleanup on close()
Closes #123
// tests/logger.test.ts
import { describe, it, expect } from "vitest";
import { createLogger } from "../src/index.js";
describe("UniversalLogger", () => {
it("should sanitize passwords", () => {
// Test implementation
});
});npm test # Run all tests
npm test -- --watch # Watch mode
npm test -- --coverage # With coverage- All new features must include tests
- Bug fixes should include regression tests
- Aim for >80% code coverage
If you want to add support for a new database:
-
Create adapter file:
src/adapters/your-db.ts -
Implement LogAdapter interface:
export class YourDBAdapter implements LogAdapter { async connect(): Promise<void> {} async write(entry: LogEntry): Promise<void> {} async query(filter: LogFilter): Promise<LogEntry[]> {} async close(): Promise<void> {} }
-
Export from
src/index.ts:export { createYourDBAdapter, YourDBAdapter } from "./adapters/your-db.js"; export type { YourDBAdapterConfig } from "./adapters/your-db.js";
-
Add example:
examples/your-db-example.js -
Update README.md with installation and usage instructions
-
Add to package.json peerDependencies
- Use clear, concise language
- Include code examples
- Keep examples up-to-date with API changes
- Add JSDoc comments to all public APIs
- Update README.md for user-facing changes
- Update CHANGELOG.md (we maintain it)
- 💬 Open a Discussion
- 🐛 Report an Issue
- 📧 Contact: [Your contact method]
Contributors will be recognized in:
- README.md Contributors section
- GitHub Contributors page
- Release notes (for significant contributions)
Thank you for contributing! 🙏
Happy Contributing! 🚀