client-debug-log-client
v1.0.0
Published
Lightweight TypeScript browser client for client-debug-log.
Maintainers
Readme
client-debug-log-client
A lightweight TypeScript-only browser client for communicating with the debug logging server created by the server-side library client-debug-log (npm).
This package hides the underlying implementation details so application code can send client debug logs through a clean, consistent interface.
Purpose
- Provide a simple API for browser-side debug logging
- Abstract transport and communication logic
- Keep application logging code focused and maintainable
Installation
npm install client-debug-log-clientUsage
import { Logger } from 'client-debug-log-client';
Logger.init({
serverUrl: 'http://localhost:3000'
});
Logger.debug('App started', { env: 'dev' });
Logger.info('User logged in', { userId: '123' });
Logger.warn('Unexpected response time', { ms: 980 });
Logger.error('Failed to load dashboard', new Error('Network error'));Call Logger.init(...) once during app startup before sending logs.
API
Logger.init({ serverUrl }): Initializes the client and connects it to your logging server.Logger.debug(...args): Sends a debug log.Logger.info(...args): Sends an info log.Logger.warn(...args): Sends a warning log.Logger.error(...args): Sends an error log.
Notes
This project is intended to be used together with the server hosted by the main client-debug-log project.
If logging methods are called before initialization, a LoggerNotInitializedError is thrown.
License
This project is licensed under the MIT License.
