tracelog-client-sdk 0.1.3 → 0.2.0
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.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -11
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare class LogStreamer {
|
|
2
2
|
private apiKey;
|
|
3
3
|
private httpClient;
|
|
4
|
-
private
|
|
4
|
+
private baseUrl;
|
|
5
5
|
constructor(apikey: string);
|
|
6
|
-
info(message: string, metadata?: object):
|
|
7
|
-
error(message: string, metadata?: object):
|
|
6
|
+
info(message: string, metadata?: object): void;
|
|
7
|
+
error(message: string, metadata?: object): void;
|
|
8
8
|
private sendLog;
|
|
9
9
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,13 +7,13 @@ exports.LogStreamer = void 0;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
class LogStreamer {
|
|
9
9
|
constructor(apikey) {
|
|
10
|
-
this.
|
|
10
|
+
this.baseUrl = 'http://localhost:3001/api/log';
|
|
11
11
|
if (!apikey) {
|
|
12
|
-
throw new Error('API key is required
|
|
12
|
+
throw new Error('[TraceLog] API key is required.');
|
|
13
13
|
}
|
|
14
14
|
this.apiKey = apikey;
|
|
15
15
|
this.httpClient = axios_1.default.create({
|
|
16
|
-
baseURL: this.
|
|
16
|
+
baseURL: this.baseUrl,
|
|
17
17
|
headers: {
|
|
18
18
|
"Authorization": `ApiKey ${this.apiKey}`,
|
|
19
19
|
"Content-Type": "application/json",
|
|
@@ -21,27 +21,24 @@ class LogStreamer {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
info(message, metadata = {}) {
|
|
24
|
-
|
|
24
|
+
this.sendLog('info', message, metadata);
|
|
25
25
|
}
|
|
26
26
|
error(message, metadata = {}) {
|
|
27
|
-
|
|
27
|
+
this.sendLog('error', message, metadata);
|
|
28
28
|
}
|
|
29
29
|
async sendLog(level, message, metadata) {
|
|
30
30
|
const payload = {
|
|
31
31
|
message,
|
|
32
32
|
level,
|
|
33
33
|
metadata,
|
|
34
|
-
timestamp: new Date().
|
|
34
|
+
timestamp: new Date().toISOString()
|
|
35
35
|
};
|
|
36
36
|
try {
|
|
37
|
-
await this.httpClient.post(
|
|
37
|
+
await this.httpClient.post('/ingest', payload);
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
40
|
if (axios_1.default.isAxiosError(error)) {
|
|
41
|
-
console.error('[
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.error('[Trace Log Api Client] Log could not be sent', error);
|
|
41
|
+
console.error('[TraceLog Error] Sunucuya ulaşılamadı:', error.message);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tracelog-client-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
9
11
|
],
|
|
10
12
|
"scripts": {
|
|
11
13
|
"build": "tsc",
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
"tracelog-saas"
|
|
21
23
|
],
|
|
22
24
|
"author": "Yakup Hadutoğlu <yakuphad2004@gmail.com>",
|
|
23
|
-
"license": "
|
|
25
|
+
"license": "MIT",
|
|
24
26
|
"dependencies": {
|
|
25
27
|
"axios": "^1.13.2"
|
|
26
28
|
},
|