https://github.com/efefurkankarakaya/logpack
A lightweight, configurable and zero-dependency logging package for React and Next.js
https://github.com/efefurkankarakaya/logpack
javascript next-logging react-logging serverside-logging ssr-logging typescript
Last synced: 18 days ago
JSON representation
A lightweight, configurable and zero-dependency logging package for React and Next.js
- Host: GitHub
- URL: https://github.com/efefurkankarakaya/logpack
- Owner: efefurkankarakaya
- License: mit
- Created: 2025-04-08T09:42:29.000Z (25 days ago)
- Default Branch: master
- Last Pushed: 2025-04-09T13:56:51.000Z (24 days ago)
- Last Synced: 2025-04-11T07:07:03.106Z (22 days ago)
- Topics: javascript, next-logging, react-logging, serverside-logging, ssr-logging, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/logpack
- Size: 28.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logpack
A lightweight and zero dependency logging package for React and Next.js.
## Installation
```bash
npm install logpack
# or
yarn add logpack
# or
pnpm add logpack
```## Usage
```typescript
import Logpack from 'logpack';// Log information
Logpack.info('Application started');// Log warnings
Logpack.warn('This feature is deprecated');// Log errors
Logpack.error('Failed to connect to the database');// Log objects
Logpack.info({ user: 'John', role: 'admin' });// Conditionally log (useful for environment-specific logging)
const isProduction = process.env.NODE_ENV === 'production';
Logpack.info('Debug message', { display: !isProduction });// Configure global settings
Logpack.configure({
locale: 'tr-TR',
displayDate: true,
displayLevel: true,
displayColor: true,
});
```## Configuration Options
```typescript
interface Config {
locale?: string; // Locale for timestamp formatting (default: 'en-US')
dateFormat?: Record; // Date formatting options
display?: boolean; // Whether to display logs (default: true)
displayColor?: boolean; // Enable colored logs (default: true)
displayDate?: boolean; // Show timestamps in logs (default: true)
displayLevel?: boolean; // Show log level (INFO, WARN, ERROR) (default: true)
}
```You can provide configuration options:
1. Globally using `Logpack.configure()`
2. Per log statement as a second parameter: `Logpack.info('message', config)`## Features
- Formatted timestamps with customizable locale and format
- Different log levels (info, warn, error)
- Automatic pretty-printing of objects on the server
- Conditional logging for environment-specific output
- Global configuration with per-log overrides
- TypeScript support
- Zero dependencies## License
MIT