1.1.2 • Published 6 months ago
@realgolfgames/logging-sdk v1.1.2
RealGolf.Games Logging SDK
A lightweight logging SDK for sending structured logs to a remote logging endpoint, including IP and geolocation data.
Features
- Automatically fetches client IP and geolocation
- Allows custom log endpoint configuration
- Clean separation of log metadata, details, and location
- Fully typed for use with TypeScript
Installation
npm install @realgolfgames/logging-sdkUsage
import createLog from '@realgolfgames/logging-sdk';
const data = await createLog(
'https://your-custom-endpoint.com/logs', // any endpoint where your api expects logs
'error', // level: "info" | "error" | "warn"
'auth', //source
'Invalid token', // message
401, // status_code
'your-costum-domain.com', // origin
'user_id', // user ID
'GET', // HTTP method
'/api/user' // path
);Parameters
| Name | Type | Description |
|---|---|---|
log_endpoint | string | Custom URL for your log server |
level | 'info' | 'error' | 'warn' | The log level |
source | string | The source module (e.g., 'auth', 'api') |
message | string | A descriptive message |
status_code | number | HTTP status code |
origin | string | Origin of the log (e.g., 'frontend') |
user_id | string | The ID of the user |
method | string | HTTP method (e.g., 'GET', 'POST') |
path | string | The API or route path |
Return Type
Promise<
| { message: string; status: number }
| { error: string; status: number }
>;The exact response depends on your logging API implementation.
License
MIT - © 2025 RealGolf.Games UG (haftungsbeschränkt)