tracelog-client-sdk 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # tracelog-client-sdk
2
+
3
+ This is the official Node.js client library for the TraceLog (TraceLog API's address or website) platform.
4
+
5
+ This SDK allows you to easily send logs and metrics from your Node.js applications to the TraceLog API. It eliminates the complexity of issuing manual POST requests with axios.
6
+
7
+ ### Özellikler
8
+ ---
9
+ -Simple and intuitive API (.info(), .error())
10
+
11
+ -Automatic API Key management
12
+
13
+ -ypeScript support (includes type definitions)
14
+
15
+ -Asynchronous log sending in the background
16
+
17
+ ## Installation
18
+ You can install the package in your project using NPM or Yarn:
19
+ ```
20
+ npm install tracelog-client-sdk
21
+ ```
22
+ 🛠️ Usage
23
+ Using the SDK is very simple. First, import the LogStreamer class and create an instance with your API Key.
24
+
25
+ JavaScript
26
+ --
27
+ ```
28
+
29
+ //JavaScript (CommonJS)
30
+ const { LogStreamer } = require('tracelog-client-sdk');
31
+
32
+ //TypeScript (ES Modules)
33
+ import { LogStreamer } from 'tracelog-client-sdk';
34
+
35
+ //1. Start the SDK with your API Key
36
+ //(You must get this API Key from your LogStream panel)
37
+ const logger = new LogStreamer('YOUR_SECRET_API_KEY_HERE');
38
+
39
+ //2. Start sending logs!
40
+
41
+ //A log at the information level
42
+ logger.info('User logged in successfully', {
43
+ userId: 'user-123',
44
+ process: 'auth'
45
+ });
46
+
47
+ //A log at the error level
48
+ try {
49
+ //... Error-potential code ...
50
+ throw new Error('Database connection broken');
51
+ } catch (error) {
52
+ logger.error(error.message, {
53
+ statusCode: 500,
54
+ component: 'database-service'
55
+ });
56
+ }
57
+ ```
58
+ Sending logs is done asynchronously in the background and does not prevent your main application from running.
59
+
60
+ ## API Reference
61
+ -new LogStreamer(apiKey)
62
+ Starts the SDK client.
63
+
64
+ -apiKey (string, Required): Your API key obtained from your LogStream panel.
65
+
66
+ -.info(message, [metadata])
67
+ Sends a log at info level.
68
+
69
+ -message (string, Required): The main log message to send.
70
+
71
+ -metadata (object, Optional): Extra JSON data to be added to the log (eg: user ID, session ID, etc.).
72
+ -.error(message, [metadata])
73
+ It sends a log at error level.
74
+
75
+ -message (string, Required): Error message.
76
+
77
+ -metadata (object, Optional): Extra context information about the error (e.g. stack trace, request ID, etc.).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tracelog-client-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Views of the official SDK for the TraceLog SaaS platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",