namirasoft-log 1.4.36 → 1.4.38

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.
@@ -1,12 +1,12 @@
1
- /src/BaseFormatter.ts
2
- /src/FormatterFull.ts
3
- /src/FormatterShort.ts
4
- /src/IFormatter.ts
5
- /src/ILogger.ts
6
- /src/IStream.ts
7
- /src/Log.ts
8
- /src/Logger.ts
9
- /src/LogLevel.ts
10
- /src/StreamConsole.ts
11
- /src/StreamFile.ts
1
+ /src/BaseFormatter.ts
2
+ /src/FormatterFull.ts
3
+ /src/FormatterShort.ts
4
+ /src/IFormatter.ts
5
+ /src/ILogger.ts
6
+ /src/IStream.ts
7
+ /src/Log.ts
8
+ /src/Logger.ts
9
+ /src/LogLevel.ts
10
+ /src/StreamConsole.ts
11
+ /src/StreamFile.ts
12
12
  /src/StreamNamirasoftLog.ts
@@ -12,7 +12,7 @@ const NamirasoftLogServerMetrics_1 = require("./NamirasoftLogServerMetrics");
12
12
  const NamirasoftLogServerValue_1 = require("./NamirasoftLogServerValue");
13
13
  class NamirasoftLogServer extends namirasoft_account_1.NSABaseServer {
14
14
  constructor(base_url, manager, onError) {
15
- super(base_url, `1.4.36`, manager, onError);
15
+ super(base_url, `1.4.37`, manager, onError);
16
16
  this.healthz = new NamirasoftLogServerHealthz_1.NamirasoftLogServerHealthz(this);
17
17
  this.metrics = new NamirasoftLogServerMetrics_1.NamirasoftLogServerMetrics(this);
18
18
  this.value = new NamirasoftLogServerValue_1.NamirasoftLogServerValue(this);
@@ -16,6 +16,7 @@ export declare class NamirasoftLogServerLogGroup extends NamirasoftLogServerBase
16
16
  }>;
17
17
  Validation(config?: BaseServerConfig<any>): Promise<SubscriptionValidation>;
18
18
  Usage(config?: BaseServerConfig<any>): Promise<{
19
+ subscribed: boolean;
19
20
  quota: {
20
21
  log_group_record_count: {
21
22
  value: number;
@@ -1 +1 @@
1
- {"version":3,"file":"NamirasoftLogServerLogGroup.js","source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ACJ;AA9DD,kEA8DC;AAAA,CAAC"}
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
- {
2
- "name": "namirasoft-log",
3
- "title": "Namirasoft Log NPM Package",
4
- "description": "Namira Software Corporation Log NPM Package",
5
- "icon": "logo.png",
6
- "logo": "https://static.namirasoft.com/image/namirasoft/log/logo/base.png",
7
- "language": "ts",
8
- "framework": "npm",
9
- "application": "package",
10
- "private": false,
11
- "version": "1.4.36",
12
- "author": "Amir Abolhasani",
13
- "license": "MIT",
14
- "main": "./dist/index.js",
15
- "types": "./dist/index.d.ts",
16
- "scripts": {
17
- "build": ""
18
- },
19
- "dependencies": {
20
- "namirasoft-core": "^1.4.94",
21
- "namirasoft-site": "^1.4.41",
22
- "namirasoft-node-cli": "^1.4.10",
23
- "namirasoft-account": "^1.4.99",
24
- "namirasoft-payment": "^1.4.132"
25
- },
26
- "bin": {
27
- "ns-log": "./dist/command/cli.js"
28
- }
1
+ {
2
+ "name": "namirasoft-log",
3
+ "title": "Namirasoft Log NPM Package",
4
+ "description": "Namira Software Corporation Log NPM Package",
5
+ "icon": "logo.png",
6
+ "logo": "https://static.namirasoft.com/image/namirasoft/log/logo/base.png",
7
+ "language": "ts",
8
+ "framework": "npm",
9
+ "application": "package",
10
+ "private": false,
11
+ "version": "1.4.38",
12
+ "author": "Amir Abolhasani",
13
+ "license": "MIT",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "scripts": {
17
+ "build": ""
18
+ },
19
+ "dependencies": {
20
+ "namirasoft-core": "^1.4.107",
21
+ "namirasoft-site": "^1.4.41",
22
+ "namirasoft-node-cli": "^1.4.10",
23
+ "namirasoft-account": "^1.4.100",
24
+ "namirasoft-payment": "^1.4.133"
25
+ },
26
+ "bin": {
27
+ "ns-log": "./dist/command/cli.js"
28
+ }
29
29
  }
@@ -1,37 +1,37 @@
1
- export abstract class BaseFormatter
2
- {
3
- protected formatDateTime(date: Date)
4
- {
5
- return this.formatDate(date) + " " + this.formatTime(date) + " UTC";
6
- }
7
- protected formatDate(date: Date)
8
- {
9
- const year = date.getUTCFullYear();
10
- const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
11
- const day = String(date.getUTCDate()).toString().padStart(2, '0');
12
- return `${year}-${month}-${day}`;
13
- }
14
- protected formatTime(date: Date)
15
- {
16
- const hours = String(date.getUTCHours()).padStart(2, '0');
17
- const minutes = String(date.getUTCMinutes()).padStart(2, '0');
18
- const seconds = String(date.getUTCSeconds()).padStart(2, '0');
19
- return `${hours}:${minutes}:${seconds}`;
20
- }
21
- protected qoute(text: string, size: number, filler: string)
22
- {
23
- let count = (size - text.length) / 2;
24
- text = text.padStart(text.length + count, filler);
25
- text = text.padEnd(size, filler);
26
- return text;
27
- }
28
- protected getMesssages(messages: any[]): string[]
29
- {
30
- return messages.map(x =>
31
- {
32
- if (typeof (x) == "object")
33
- return JSON.stringify(x, undefined, 4);
34
- return x + "";
35
- });
36
- }
1
+ export abstract class BaseFormatter
2
+ {
3
+ protected formatDateTime(date: Date)
4
+ {
5
+ return this.formatDate(date) + " " + this.formatTime(date) + " UTC";
6
+ }
7
+ protected formatDate(date: Date)
8
+ {
9
+ const year = date.getUTCFullYear();
10
+ const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
11
+ const day = String(date.getUTCDate()).toString().padStart(2, '0');
12
+ return `${year}-${month}-${day}`;
13
+ }
14
+ protected formatTime(date: Date)
15
+ {
16
+ const hours = String(date.getUTCHours()).padStart(2, '0');
17
+ const minutes = String(date.getUTCMinutes()).padStart(2, '0');
18
+ const seconds = String(date.getUTCSeconds()).padStart(2, '0');
19
+ return `${hours}:${minutes}:${seconds}`;
20
+ }
21
+ protected qoute(text: string, size: number, filler: string)
22
+ {
23
+ let count = (size - text.length) / 2;
24
+ text = text.padStart(text.length + count, filler);
25
+ text = text.padEnd(size, filler);
26
+ return text;
27
+ }
28
+ protected getMesssages(messages: any[]): string[]
29
+ {
30
+ return messages.map(x =>
31
+ {
32
+ if (typeof (x) == "object")
33
+ return JSON.stringify(x, undefined, 4);
34
+ return x + "";
35
+ });
36
+ }
37
37
  }
@@ -1,20 +1,20 @@
1
- import { BaseFormatter } from "./BaseFormatter";
2
- import { IFormatter } from "./IFormatter";
3
- import { Log } from "./Log";
4
- import { LogLevel } from "./LogLevel";
5
-
6
- export class FormatterFull extends BaseFormatter implements IFormatter
7
- {
8
- format(log: Log): { pre: string[], messages: string[], post: string[] }
9
- {
10
- let pre: string[] = [];
11
- let messages: string[] = [];
12
- let post: string[] = [];
13
- pre.push(this.qoute(this.formatDateTime(log.date), 100, '-'));
14
- pre.push("Level: " + LogLevel[log.level]);
15
- messages.push(...this.getMesssages(log.messages));
16
- post.push(this.qoute("", 100, '-'));
17
- post.push("");
18
- return { pre, messages, post };
19
- }
1
+ import { BaseFormatter } from "./BaseFormatter";
2
+ import { IFormatter } from "./IFormatter";
3
+ import { Log } from "./Log";
4
+ import { LogLevel } from "./LogLevel";
5
+
6
+ export class FormatterFull extends BaseFormatter implements IFormatter
7
+ {
8
+ format(log: Log): { pre: string[], messages: string[], post: string[] }
9
+ {
10
+ let pre: string[] = [];
11
+ let messages: string[] = [];
12
+ let post: string[] = [];
13
+ pre.push(this.qoute(this.formatDateTime(log.date), 100, '-'));
14
+ pre.push("Level: " + LogLevel[log.level]);
15
+ messages.push(...this.getMesssages(log.messages));
16
+ post.push(this.qoute("", 100, '-'));
17
+ post.push("");
18
+ return { pre, messages, post };
19
+ }
20
20
  }
@@ -1,13 +1,13 @@
1
- import { BaseFormatter } from "./BaseFormatter";
2
- import { IFormatter } from "./IFormatter";
3
- import { Log } from "./Log";
4
-
5
- export class FormatterShort extends BaseFormatter implements IFormatter
6
- {
7
- format(log: Log): { pre: string[], messages: string[], post: string[] }
8
- {
9
- let ans: string[] = [];
10
- ans.push(this.formatDateTime(log.date) + ": " + this.getMesssages(log.messages).filter(m => m).join(" - "));
11
- return { pre: [], messages: ans, post: [] };
12
- }
1
+ import { BaseFormatter } from "./BaseFormatter";
2
+ import { IFormatter } from "./IFormatter";
3
+ import { Log } from "./Log";
4
+
5
+ export class FormatterShort extends BaseFormatter implements IFormatter
6
+ {
7
+ format(log: Log): { pre: string[], messages: string[], post: string[] }
8
+ {
9
+ let ans: string[] = [];
10
+ ans.push(this.formatDateTime(log.date) + ": " + this.getMesssages(log.messages).filter(m => m).join(" - "));
11
+ return { pre: [], messages: ans, post: [] };
12
+ }
13
13
  }
package/src/IFormatter.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Log } from "./Log";
2
-
3
- export interface IFormatter
4
- {
5
- format(log: Log): { pre: string[], messages: string[], post: string[] };
1
+ import { Log } from "./Log";
2
+
3
+ export interface IFormatter
4
+ {
5
+ format(log: Log): { pre: string[], messages: string[], post: string[] };
6
6
  }
package/src/ILogger.ts CHANGED
@@ -1,18 +1,18 @@
1
- import { LogLevel } from "./LogLevel";
2
-
3
- export interface ILogger
4
- {
5
- log(level: LogLevel, ...messages: any[]): void;
6
- trace(...messages: any[]): void;
7
- verbose(...messages: any[]): void;
8
- debug(...messages: any[]): void;
9
- info(...messages: any[]): void;
10
- success(...messages: any[]): void;
11
- warning(...messages: any[]): void;
12
- error(...messages: any[]): void;
13
- critical(...messages: any[]): void;
14
- fatal(...messages: any[]): void;
15
- onCatchError(error: Error | unknown): void;
16
- onCatchCritical(error: Error | unknown): void;
17
- onCatchFatal(error: Error | unknown): void;
1
+ import { LogLevel } from "./LogLevel";
2
+
3
+ export interface ILogger
4
+ {
5
+ log(level: LogLevel, ...messages: any[]): void;
6
+ trace(...messages: any[]): void;
7
+ verbose(...messages: any[]): void;
8
+ debug(...messages: any[]): void;
9
+ info(...messages: any[]): void;
10
+ success(...messages: any[]): void;
11
+ warning(...messages: any[]): void;
12
+ error(...messages: any[]): void;
13
+ critical(...messages: any[]): void;
14
+ fatal(...messages: any[]): void;
15
+ onCatchError(error: Error | unknown): void;
16
+ onCatchCritical(error: Error | unknown): void;
17
+ onCatchFatal(error: Error | unknown): void;
18
18
  }
package/src/IStream.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Log } from "./Log";
2
- export interface IStream
3
- {
4
- write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void;
1
+ import { Log } from "./Log";
2
+ export interface IStream
3
+ {
4
+ write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void;
5
5
  }
package/src/Log.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { LogLevel } from "./LogLevel";
2
-
3
- export class Log
4
- {
5
- date: Date;
6
- level: LogLevel;
7
- messages: any[];
8
- constructor(level: LogLevel, ...messages: any[])
9
- {
10
- this.date = new Date();
11
- this.level = level;
12
- this.messages = messages;
13
- }
1
+ import { LogLevel } from "./LogLevel";
2
+
3
+ export class Log
4
+ {
5
+ date: Date;
6
+ level: LogLevel;
7
+ messages: any[];
8
+ constructor(level: LogLevel, ...messages: any[])
9
+ {
10
+ this.date = new Date();
11
+ this.level = level;
12
+ this.messages = messages;
13
+ }
14
14
  }
package/src/LogLevel.ts CHANGED
@@ -1,12 +1,12 @@
1
- export enum LogLevel
2
- {
3
- Trace = "Trace",
4
- Verbose = "Verbose",
5
- Debug = "Debug",
6
- Info = "Info",
7
- Success = "Success",
8
- Warning = "Warning",
9
- Error = "Error",
10
- Critical = "Critical",
11
- Fatal = "Fatal"
1
+ export enum LogLevel
2
+ {
3
+ Trace = "Trace",
4
+ Verbose = "Verbose",
5
+ Debug = "Debug",
6
+ Info = "Info",
7
+ Success = "Success",
8
+ Warning = "Warning",
9
+ Error = "Error",
10
+ Critical = "Critical",
11
+ Fatal = "Fatal"
12
12
  }
package/src/Logger.ts CHANGED
@@ -1,127 +1,127 @@
1
- import { FormatterFull } from "./FormatterFull";
2
- import { IFormatter } from "./IFormatter";
3
- import { ILogger } from "./ILogger";
4
- import { IStream } from "./IStream";
5
- import { Log } from "./Log";
6
- import { LogLevel } from "./LogLevel";
7
- import { StreamConsole } from "./StreamConsole";
8
-
9
- export class Logger implements ILogger
10
- {
11
- static main: Logger | null = null;
12
- private defaultStream: IStream = new StreamConsole();
13
- private formatter?: IFormatter = new FormatterFull();
14
- private customFormatter: { [level: string]: IFormatter } = {};
15
- private streams: IStream[] = [];
16
- constructor()
17
- {
18
- if (Logger.main == null)
19
- Logger.main = this;
20
- this.setFromatter = this.setFromatter.bind(this);
21
- this.setCustomFormatter = this.setCustomFormatter.bind(this);
22
- this.addStream = this.addStream.bind(this);
23
- this.log = this.log.bind(this);
24
- this.trace = this.trace.bind(this);
25
- this.verbose = this.verbose.bind(this);
26
- this.debug = this.debug.bind(this);
27
- this.info = this.info.bind(this);
28
- this.success = this.success.bind(this);
29
- this.warning = this.warning.bind(this);
30
- this.error = this.error.bind(this);
31
- this.critical = this.critical.bind(this);
32
- this.fatal = this.fatal.bind(this);
33
- this.onCatchError = this.onCatchError.bind(this);
34
- this.onCatchCritical = this.onCatchCritical.bind(this);
35
- this.onCatchFatal = this.onCatchFatal.bind(this);
36
- this.getErrorMessage = this.getErrorMessage.bind(this);
37
- this.getErrorStack = this.getErrorStack.bind(this);
38
- this.initUncought = this.initUncought.bind(this);
39
- }
40
- setFromatter(formatter: IFormatter): void
41
- {
42
- this.formatter = formatter;
43
- }
44
- setCustomFormatter(level: LogLevel, formatter: IFormatter): void
45
- {
46
- this.customFormatter[level] = formatter;
47
- }
48
- addStream(stream: IStream)
49
- {
50
- this.streams.push(stream);
51
- }
52
- log(level: LogLevel, ...messages: any[])
53
- {
54
- let log = new Log(level, ...messages);
55
- let formatted: { pre: string[], messages: string[], post: string[] } = { pre: [], messages: [], post: [] };
56
- let formatter = this.customFormatter[level.toString()] ?? this.formatter;
57
- if (formatter)
58
- formatted = formatter.format(log);
59
- if (this.streams.length == 0)
60
- this.defaultStream.write(log, formatted);
61
- else
62
- this.streams.map(s => s.write(log, formatted));
63
- }
64
- trace(...messages: any[])
65
- {
66
- this.log(LogLevel.Trace, ...messages);
67
- }
68
- verbose(...messages: any[])
69
- {
70
- this.log(LogLevel.Verbose, ...messages);
71
- }
72
- debug(...messages: any[])
73
- {
74
- this.log(LogLevel.Debug, ...messages);
75
- }
76
- info(...messages: any[])
77
- {
78
- this.log(LogLevel.Info, ...messages);
79
- }
80
- success(...messages: any[])
81
- {
82
- this.log(LogLevel.Success, ...messages);
83
- }
84
- warning(...messages: any[])
85
- {
86
- this.log(LogLevel.Warning, ...messages);
87
- }
88
- error(...messages: any[])
89
- {
90
- this.log(LogLevel.Error, ...messages);
91
- }
92
- critical(...messages: any[])
93
- {
94
- this.log(LogLevel.Critical, ...messages);
95
- }
96
- fatal(...messages: any[])
97
- {
98
- this.log(LogLevel.Fatal, ...messages);
99
- }
100
- onCatchError(error: Error | unknown)
101
- {
102
- this.error(this.getErrorMessage(error), this.getErrorStack(error));
103
- }
104
- onCatchCritical(error: Error | unknown)
105
- {
106
- this.critical(this.getErrorMessage(error), this.getErrorStack(error));
107
- }
108
- onCatchFatal(error: Error | unknown)
109
- {
110
- this.fatal(this.getErrorMessage(error), this.getErrorStack(error));
111
- }
112
- protected getErrorMessage(error: Error | unknown): string
113
- {
114
- if (error instanceof Error)
115
- return error.message;
116
- return error + "";
117
- }
118
- protected getErrorStack(error: Error | unknown): string
119
- {
120
- if (error instanceof Error)
121
- return error.stack ?? "";
122
- return error + "";
123
- }
124
- initUncought()
125
- {
126
- }
1
+ import { FormatterFull } from "./FormatterFull";
2
+ import { IFormatter } from "./IFormatter";
3
+ import { ILogger } from "./ILogger";
4
+ import { IStream } from "./IStream";
5
+ import { Log } from "./Log";
6
+ import { LogLevel } from "./LogLevel";
7
+ import { StreamConsole } from "./StreamConsole";
8
+
9
+ export class Logger implements ILogger
10
+ {
11
+ static main: Logger | null = null;
12
+ private defaultStream: IStream = new StreamConsole();
13
+ private formatter?: IFormatter = new FormatterFull();
14
+ private customFormatter: { [level: string]: IFormatter } = {};
15
+ private streams: IStream[] = [];
16
+ constructor()
17
+ {
18
+ if (Logger.main == null)
19
+ Logger.main = this;
20
+ this.setFromatter = this.setFromatter.bind(this);
21
+ this.setCustomFormatter = this.setCustomFormatter.bind(this);
22
+ this.addStream = this.addStream.bind(this);
23
+ this.log = this.log.bind(this);
24
+ this.trace = this.trace.bind(this);
25
+ this.verbose = this.verbose.bind(this);
26
+ this.debug = this.debug.bind(this);
27
+ this.info = this.info.bind(this);
28
+ this.success = this.success.bind(this);
29
+ this.warning = this.warning.bind(this);
30
+ this.error = this.error.bind(this);
31
+ this.critical = this.critical.bind(this);
32
+ this.fatal = this.fatal.bind(this);
33
+ this.onCatchError = this.onCatchError.bind(this);
34
+ this.onCatchCritical = this.onCatchCritical.bind(this);
35
+ this.onCatchFatal = this.onCatchFatal.bind(this);
36
+ this.getErrorMessage = this.getErrorMessage.bind(this);
37
+ this.getErrorStack = this.getErrorStack.bind(this);
38
+ this.initUncought = this.initUncought.bind(this);
39
+ }
40
+ setFromatter(formatter: IFormatter): void
41
+ {
42
+ this.formatter = formatter;
43
+ }
44
+ setCustomFormatter(level: LogLevel, formatter: IFormatter): void
45
+ {
46
+ this.customFormatter[level] = formatter;
47
+ }
48
+ addStream(stream: IStream)
49
+ {
50
+ this.streams.push(stream);
51
+ }
52
+ log(level: LogLevel, ...messages: any[])
53
+ {
54
+ let log = new Log(level, ...messages);
55
+ let formatted: { pre: string[], messages: string[], post: string[] } = { pre: [], messages: [], post: [] };
56
+ let formatter = this.customFormatter[level.toString()] ?? this.formatter;
57
+ if (formatter)
58
+ formatted = formatter.format(log);
59
+ if (this.streams.length == 0)
60
+ this.defaultStream.write(log, formatted);
61
+ else
62
+ this.streams.map(s => s.write(log, formatted));
63
+ }
64
+ trace(...messages: any[])
65
+ {
66
+ this.log(LogLevel.Trace, ...messages);
67
+ }
68
+ verbose(...messages: any[])
69
+ {
70
+ this.log(LogLevel.Verbose, ...messages);
71
+ }
72
+ debug(...messages: any[])
73
+ {
74
+ this.log(LogLevel.Debug, ...messages);
75
+ }
76
+ info(...messages: any[])
77
+ {
78
+ this.log(LogLevel.Info, ...messages);
79
+ }
80
+ success(...messages: any[])
81
+ {
82
+ this.log(LogLevel.Success, ...messages);
83
+ }
84
+ warning(...messages: any[])
85
+ {
86
+ this.log(LogLevel.Warning, ...messages);
87
+ }
88
+ error(...messages: any[])
89
+ {
90
+ this.log(LogLevel.Error, ...messages);
91
+ }
92
+ critical(...messages: any[])
93
+ {
94
+ this.log(LogLevel.Critical, ...messages);
95
+ }
96
+ fatal(...messages: any[])
97
+ {
98
+ this.log(LogLevel.Fatal, ...messages);
99
+ }
100
+ onCatchError(error: Error | unknown)
101
+ {
102
+ this.error(this.getErrorMessage(error), this.getErrorStack(error));
103
+ }
104
+ onCatchCritical(error: Error | unknown)
105
+ {
106
+ this.critical(this.getErrorMessage(error), this.getErrorStack(error));
107
+ }
108
+ onCatchFatal(error: Error | unknown)
109
+ {
110
+ this.fatal(this.getErrorMessage(error), this.getErrorStack(error));
111
+ }
112
+ protected getErrorMessage(error: Error | unknown): string
113
+ {
114
+ if (error instanceof Error)
115
+ return error.message;
116
+ return error + "";
117
+ }
118
+ protected getErrorStack(error: Error | unknown): string
119
+ {
120
+ if (error instanceof Error)
121
+ return error.stack ?? "";
122
+ return error + "";
123
+ }
124
+ initUncought()
125
+ {
126
+ }
127
127
  }
@@ -1,54 +1,54 @@
1
- /****************************************************************/
2
- /* */
3
- /* This is an Auto-Generated File */
4
- /* Made By */
5
- /* Namirasoft SDK Generator NPM Package */
6
- /* */
7
- /****************************************************************/
8
- /****************************************************************/
9
- /* */
10
- /* Please do not make any change to this file */
11
- /* If any change is required, ns-sdkg command must be used */
12
- /* */
13
- /****************************************************************/
14
- /****************************************************************/
15
- /* */
16
- /* Namira Software Corporation */
17
- /* https://namirasoft.com */
18
- /* */
19
- /****************************************************************/
20
-
21
- import { NSABaseServer } from "namirasoft-account";
22
- import { NamirasoftLogServerHealthz } from "./NamirasoftLogServerHealthz";
23
- import { NamirasoftLogServerLog } from "./NamirasoftLogServerLog";
24
- import { NamirasoftLogServerLogGroup } from "./NamirasoftLogServerLogGroup";
25
- import { NamirasoftLogServerLogGroupCategory } from "./NamirasoftLogServerLogGroupCategory";
26
- import { NamirasoftLogServerLogGroupField } from "./NamirasoftLogServerLogGroupField";
27
- import { NamirasoftLogServerLogGroupTag } from "./NamirasoftLogServerLogGroupTag";
28
- import { NamirasoftLogServerMetrics } from "./NamirasoftLogServerMetrics";
29
- import { NamirasoftLogServerValue } from "./NamirasoftLogServerValue";
30
- import { TokenManager } from "namirasoft-account";
31
-
32
- export class NamirasoftLogServer extends NSABaseServer
33
- {
34
- healthz: NamirasoftLogServerHealthz;
35
- metrics: NamirasoftLogServerMetrics;
36
- value: NamirasoftLogServerValue;
37
- log_group_category: NamirasoftLogServerLogGroupCategory;
38
- log_group_field: NamirasoftLogServerLogGroupField;
39
- log_group_tag: NamirasoftLogServerLogGroupTag;
40
- log_group: NamirasoftLogServerLogGroup;
41
- log: NamirasoftLogServerLog;
42
- constructor(base_url: string, manager: TokenManager, onError: (error: Error) => void)
43
- {
44
- super(base_url, `1.4.36`, manager, onError);
45
- this.healthz = new NamirasoftLogServerHealthz(this);
46
- this.metrics = new NamirasoftLogServerMetrics(this);
47
- this.value = new NamirasoftLogServerValue(this);
48
- this.log_group_category = new NamirasoftLogServerLogGroupCategory(this);
49
- this.log_group_field = new NamirasoftLogServerLogGroupField(this);
50
- this.log_group_tag = new NamirasoftLogServerLogGroupTag(this);
51
- this.log_group = new NamirasoftLogServerLogGroup(this);
52
- this.log = new NamirasoftLogServerLog(this);
53
- }
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { NSABaseServer } from "namirasoft-account";
22
+ import { NamirasoftLogServerHealthz } from "./NamirasoftLogServerHealthz";
23
+ import { NamirasoftLogServerLog } from "./NamirasoftLogServerLog";
24
+ import { NamirasoftLogServerLogGroup } from "./NamirasoftLogServerLogGroup";
25
+ import { NamirasoftLogServerLogGroupCategory } from "./NamirasoftLogServerLogGroupCategory";
26
+ import { NamirasoftLogServerLogGroupField } from "./NamirasoftLogServerLogGroupField";
27
+ import { NamirasoftLogServerLogGroupTag } from "./NamirasoftLogServerLogGroupTag";
28
+ import { NamirasoftLogServerMetrics } from "./NamirasoftLogServerMetrics";
29
+ import { NamirasoftLogServerValue } from "./NamirasoftLogServerValue";
30
+ import { TokenManager } from "namirasoft-account";
31
+
32
+ export class NamirasoftLogServer extends NSABaseServer
33
+ {
34
+ healthz: NamirasoftLogServerHealthz;
35
+ metrics: NamirasoftLogServerMetrics;
36
+ value: NamirasoftLogServerValue;
37
+ log_group_category: NamirasoftLogServerLogGroupCategory;
38
+ log_group_field: NamirasoftLogServerLogGroupField;
39
+ log_group_tag: NamirasoftLogServerLogGroupTag;
40
+ log_group: NamirasoftLogServerLogGroup;
41
+ log: NamirasoftLogServerLog;
42
+ constructor(base_url: string, manager: TokenManager, onError: (error: Error) => void)
43
+ {
44
+ super(base_url, `1.4.37`, manager, onError);
45
+ this.healthz = new NamirasoftLogServerHealthz(this);
46
+ this.metrics = new NamirasoftLogServerMetrics(this);
47
+ this.value = new NamirasoftLogServerValue(this);
48
+ this.log_group_category = new NamirasoftLogServerLogGroupCategory(this);
49
+ this.log_group_field = new NamirasoftLogServerLogGroupField(this);
50
+ this.log_group_tag = new NamirasoftLogServerLogGroupTag(this);
51
+ this.log_group = new NamirasoftLogServerLogGroup(this);
52
+ this.log = new NamirasoftLogServerLog(this);
53
+ }
54
54
  };
@@ -1,93 +1,93 @@
1
- /****************************************************************/
2
- /* */
3
- /* This is an Auto-Generated File */
4
- /* Made By */
5
- /* Namirasoft SDK Generator NPM Package */
6
- /* */
7
- /****************************************************************/
8
- /****************************************************************/
9
- /* */
10
- /* Please do not make any change to this file */
11
- /* If any change is required, ns-sdkg command must be used */
12
- /* */
13
- /****************************************************************/
14
- /****************************************************************/
15
- /* */
16
- /* Namira Software Corporation */
17
- /* https://namirasoft.com */
18
- /* */
19
- /****************************************************************/
20
-
21
- import { BaseServerConfig } from "namirasoft-core";
22
- import { FilterItem } from "namirasoft-core";
23
- import { LogGroupFullRow } from "./row/LogGroupFullRow";
24
- import { LogGroupInputRow } from "./row/LogGroupInputRow";
25
- import { LogGroupRow } from "./row/LogGroupRow";
26
- import { NamirasoftLogServer } from "./NamirasoftLogServer";
27
- import { NamirasoftLogServerBase } from "./NamirasoftLogServerBase";
28
- import { SortItem } from "namirasoft-core";
29
- import { SubscriptionValidation } from "namirasoft-payment";
30
-
31
- export class NamirasoftLogServerLogGroup extends NamirasoftLogServerBase
32
- {
33
- constructor(server: NamirasoftLogServer)
34
- {
35
- super(server);
36
- this._CancelationCheck = this._CancelationCheck.bind(this);
37
- this.List = this.List.bind(this);
38
- this.Validation = this.Validation.bind(this);
39
- this.Usage = this.Usage.bind(this);
40
- this.Get = this.Get.bind(this);
41
- this.Create = this.Create.bind(this);
42
- this.Update = this.Update.bind(this);
43
- this.Delete = this.Delete.bind(this);
44
- }
45
- async _CancelationCheck(user_id: string, config?: BaseServerConfig<any>): Promise<void>
46
- {
47
- let path = `/application/user/${user_id}/log/group/cancelation/condition`;
48
- await this.server._get<void>(path, {}, config);
49
- }
50
- async List(filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[], config?: BaseServerConfig<any>): Promise<{ rows: LogGroupRow[], count: number }>
51
- {
52
- let filters_string_value: string = FilterItem.stringify(filters);
53
- let sorts_string_value: string = SortItem.stringify(sorts);
54
- let path = `/log/group/list`;
55
- let { data } = await this.server._get<{ rows: LogGroupRow[], count: number }>(path, { filters: filters_string_value, page, size, sorts: sorts_string_value }, config);
56
- return data;
57
- }
58
- async Validation(config?: BaseServerConfig<any>): Promise<SubscriptionValidation>
59
- {
60
- let path = `/log/group/validation`;
61
- let { data } = await this.server._get<SubscriptionValidation>(path, {}, config);
62
- return data;
63
- }
64
- async Usage(config?: BaseServerConfig<any>): Promise<{ quota: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } }, used: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } } }>
65
- {
66
- let path = `/log/group/usage`;
67
- let { data } = await this.server._get<{ quota: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } }, used: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } } }>(path, {}, config);
68
- return data;
69
- }
70
- async Get(id: string, config?: BaseServerConfig<any>): Promise<LogGroupFullRow>
71
- {
72
- let path = `/log/group/${id}`;
73
- let { data } = await this.server._get<LogGroupFullRow>(path, {}, config);
74
- return data;
75
- }
76
- async Create(body: LogGroupInputRow, config?: BaseServerConfig<any>): Promise<LogGroupRow>
77
- {
78
- let path = `/log/group`;
79
- let { data } = await this.server._post<LogGroupRow>(path, {}, body, config);
80
- return data;
81
- }
82
- async Update(id: string, body: LogGroupInputRow, config?: BaseServerConfig<any>): Promise<LogGroupRow>
83
- {
84
- let path = `/log/group/${id}`;
85
- let { data } = await this.server._put<LogGroupRow>(path, {}, body, config);
86
- return data;
87
- }
88
- async Delete(id: string, config?: BaseServerConfig<any>): Promise<void>
89
- {
90
- let path = `/log/group/${id}`;
91
- await this.server._delete<void>(path, {}, config);
92
- }
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseServerConfig } from "namirasoft-core";
22
+ import { FilterItem } from "namirasoft-core";
23
+ import { LogGroupFullRow } from "./row/LogGroupFullRow";
24
+ import { LogGroupInputRow } from "./row/LogGroupInputRow";
25
+ import { LogGroupRow } from "./row/LogGroupRow";
26
+ import { NamirasoftLogServer } from "./NamirasoftLogServer";
27
+ import { NamirasoftLogServerBase } from "./NamirasoftLogServerBase";
28
+ import { SortItem } from "namirasoft-core";
29
+ import { SubscriptionValidation } from "namirasoft-payment";
30
+
31
+ export class NamirasoftLogServerLogGroup extends NamirasoftLogServerBase
32
+ {
33
+ constructor(server: NamirasoftLogServer)
34
+ {
35
+ super(server);
36
+ this._CancelationCheck = this._CancelationCheck.bind(this);
37
+ this.List = this.List.bind(this);
38
+ this.Validation = this.Validation.bind(this);
39
+ this.Usage = this.Usage.bind(this);
40
+ this.Get = this.Get.bind(this);
41
+ this.Create = this.Create.bind(this);
42
+ this.Update = this.Update.bind(this);
43
+ this.Delete = this.Delete.bind(this);
44
+ }
45
+ async _CancelationCheck(user_id: string, config?: BaseServerConfig<any>): Promise<void>
46
+ {
47
+ let path = `/application/user/${user_id}/log/group/cancelation/condition`;
48
+ await this.server._get<void>(path, {}, config);
49
+ }
50
+ async List(filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[], config?: BaseServerConfig<any>): Promise<{ rows: LogGroupRow[], count: number }>
51
+ {
52
+ let filters_string_value: string = FilterItem.stringify(filters);
53
+ let sorts_string_value: string = SortItem.stringify(sorts);
54
+ let path = `/log/group/list`;
55
+ let { data } = await this.server._get<{ rows: LogGroupRow[], count: number }>(path, { filters: filters_string_value, page, size, sorts: sorts_string_value }, config);
56
+ return data;
57
+ }
58
+ async Validation(config?: BaseServerConfig<any>): Promise<SubscriptionValidation>
59
+ {
60
+ let path = `/log/group/validation`;
61
+ let { data } = await this.server._get<SubscriptionValidation>(path, {}, config);
62
+ return data;
63
+ }
64
+ async Usage(config?: BaseServerConfig<any>): Promise<{ subscribed: boolean, quota: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } }, used: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } } }>
65
+ {
66
+ let path = `/log/group/usage`;
67
+ let { data } = await this.server._get<{ subscribed: boolean, quota: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } }, used: { log_group_record_count: { value: number, unit: string }, log_record_size: { value: number, unit: string }, log_read_size: { value: number, unit: string } } }>(path, {}, config);
68
+ return data;
69
+ }
70
+ async Get(id: string, config?: BaseServerConfig<any>): Promise<LogGroupFullRow>
71
+ {
72
+ let path = `/log/group/${id}`;
73
+ let { data } = await this.server._get<LogGroupFullRow>(path, {}, config);
74
+ return data;
75
+ }
76
+ async Create(body: LogGroupInputRow, config?: BaseServerConfig<any>): Promise<LogGroupRow>
77
+ {
78
+ let path = `/log/group`;
79
+ let { data } = await this.server._post<LogGroupRow>(path, {}, body, config);
80
+ return data;
81
+ }
82
+ async Update(id: string, body: LogGroupInputRow, config?: BaseServerConfig<any>): Promise<LogGroupRow>
83
+ {
84
+ let path = `/log/group/${id}`;
85
+ let { data } = await this.server._put<LogGroupRow>(path, {}, body, config);
86
+ return data;
87
+ }
88
+ async Delete(id: string, config?: BaseServerConfig<any>): Promise<void>
89
+ {
90
+ let path = `/log/group/${id}`;
91
+ await this.server._delete<void>(path, {}, config);
92
+ }
93
93
  };
@@ -1,38 +1,38 @@
1
- import { ConsoleOperation } from "namirasoft-core";
2
- import { IStream } from "./IStream";
3
- import { Log } from "./Log";
4
- import { LogLevel } from './LogLevel';
5
-
6
- export class StreamConsole implements IStream
7
- {
8
- write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
9
- {
10
- let getFormatted = (data: string) =>
11
- {
12
- if (log.level == LogLevel.Trace)
13
- return ConsoleOperation.formatTraceColor(data);
14
- if (log.level == LogLevel.Verbose)
15
- return ConsoleOperation.formatLogColor(data);
16
- if (log.level == LogLevel.Debug)
17
- return ConsoleOperation.formatDebugColor(data);
18
- if (log.level == LogLevel.Info)
19
- return ConsoleOperation.formatInfoColor(data);
20
- if (log.level == LogLevel.Success)
21
- return ConsoleOperation.formatSuccessColor(data);
22
- if (log.level == LogLevel.Warning)
23
- return ConsoleOperation.formatWarningColor(data);
24
- if (log.level == LogLevel.Error)
25
- return ConsoleOperation.formatErrorColor(data);
26
- if (log.level == LogLevel.Critical)
27
- return ConsoleOperation.formatErrorColor(data);
28
- if (log.level == LogLevel.Fatal)
29
- return ConsoleOperation.formatErrorColor(data);
30
- return ConsoleOperation.formatLogColor(data);
31
- }
32
- let preline: string[] = formated.pre.map(ConsoleOperation.formatLogColor);
33
- let msgline: string[] = formated.messages.map(getFormatted);
34
- let postline: string[] = formated.post.map(ConsoleOperation.formatLogColor);
35
- let lines = [...preline, ...msgline, ...postline];
36
- console.log(lines.join("\n"));
37
- }
1
+ import { ConsoleOperation } from "namirasoft-core";
2
+ import { IStream } from "./IStream";
3
+ import { Log } from "./Log";
4
+ import { LogLevel } from './LogLevel';
5
+
6
+ export class StreamConsole implements IStream
7
+ {
8
+ write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
9
+ {
10
+ let getFormatted = (data: string) =>
11
+ {
12
+ if (log.level == LogLevel.Trace)
13
+ return ConsoleOperation.formatTraceColor(data);
14
+ if (log.level == LogLevel.Verbose)
15
+ return ConsoleOperation.formatLogColor(data);
16
+ if (log.level == LogLevel.Debug)
17
+ return ConsoleOperation.formatDebugColor(data);
18
+ if (log.level == LogLevel.Info)
19
+ return ConsoleOperation.formatInfoColor(data);
20
+ if (log.level == LogLevel.Success)
21
+ return ConsoleOperation.formatSuccessColor(data);
22
+ if (log.level == LogLevel.Warning)
23
+ return ConsoleOperation.formatWarningColor(data);
24
+ if (log.level == LogLevel.Error)
25
+ return ConsoleOperation.formatErrorColor(data);
26
+ if (log.level == LogLevel.Critical)
27
+ return ConsoleOperation.formatErrorColor(data);
28
+ if (log.level == LogLevel.Fatal)
29
+ return ConsoleOperation.formatErrorColor(data);
30
+ return ConsoleOperation.formatLogColor(data);
31
+ }
32
+ let preline: string[] = formated.pre.map(ConsoleOperation.formatLogColor);
33
+ let msgline: string[] = formated.messages.map(getFormatted);
34
+ let postline: string[] = formated.post.map(ConsoleOperation.formatLogColor);
35
+ let lines = [...preline, ...msgline, ...postline];
36
+ console.log(lines.join("\n"));
37
+ }
38
38
  }
package/src/StreamFile.ts CHANGED
@@ -1,48 +1,48 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { IStream } from "./IStream";
4
- import { Log } from "./Log";
5
-
6
- export class StreamFile implements IStream
7
- {
8
- private baseName: string;
9
- private basePath: string;
10
- seprateByDate: boolean = true;
11
- seprateByLevel: boolean = true;
12
- constructor(basePath: string = "./")
13
- {
14
- this.basePath = basePath;
15
- this.baseName = this.getPackageName();
16
- }
17
- private getPackageName()
18
- {
19
- let pkgPath = path.resolve(process.cwd(), "");
20
- if (!pkgPath.endsWith('package.json'))
21
- {
22
- pkgPath = path.join(pkgPath, 'package.json');
23
- }
24
- if (fs.existsSync(pkgPath))
25
- {
26
- let json = fs.readFileSync(pkgPath) + "";
27
- let pkg = JSON.parse(json);
28
- return pkg.name;
29
- }
30
- return "";
31
- }
32
- private getFilePath(log: Log): string
33
- {
34
- let names = [this.baseName];
35
- if (this.seprateByDate)
36
- names.push(log.date.getFullYear() + "-" + (log.date.getMonth() + 1) + "-" + log.date.getDate());
37
- if (this.seprateByLevel)
38
- names.push(log.level + "");
39
- names.push(".log");
40
- let name = names.join("-");
41
- return path.resolve(this.basePath, name);
42
- }
43
- write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
44
- {
45
- let filePath = this.getFilePath(log);
46
- fs.appendFile(filePath, [...formated.pre, ...formated.messages, ...formated.post].join("\n"), () => { });
47
- }
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { IStream } from "./IStream";
4
+ import { Log } from "./Log";
5
+
6
+ export class StreamFile implements IStream
7
+ {
8
+ private baseName: string;
9
+ private basePath: string;
10
+ seprateByDate: boolean = true;
11
+ seprateByLevel: boolean = true;
12
+ constructor(basePath: string = "./")
13
+ {
14
+ this.basePath = basePath;
15
+ this.baseName = this.getPackageName();
16
+ }
17
+ private getPackageName()
18
+ {
19
+ let pkgPath = path.resolve(process.cwd(), "");
20
+ if (!pkgPath.endsWith('package.json'))
21
+ {
22
+ pkgPath = path.join(pkgPath, 'package.json');
23
+ }
24
+ if (fs.existsSync(pkgPath))
25
+ {
26
+ let json = fs.readFileSync(pkgPath) + "";
27
+ let pkg = JSON.parse(json);
28
+ return pkg.name;
29
+ }
30
+ return "";
31
+ }
32
+ private getFilePath(log: Log): string
33
+ {
34
+ let names = [this.baseName];
35
+ if (this.seprateByDate)
36
+ names.push(log.date.getFullYear() + "-" + (log.date.getMonth() + 1) + "-" + log.date.getDate());
37
+ if (this.seprateByLevel)
38
+ names.push(log.level + "");
39
+ names.push(".log");
40
+ let name = names.join("-");
41
+ return path.resolve(this.basePath, name);
42
+ }
43
+ write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
44
+ {
45
+ let filePath = this.getFilePath(log);
46
+ fs.appendFile(filePath, [...formated.pre, ...formated.messages, ...formated.post].join("\n"), () => { });
47
+ }
48
48
  }
@@ -1,65 +1,65 @@
1
- import { IStream } from "./IStream";
2
- import { Log } from "./Log";
3
- import { NamirasoftLogServer } from "./NamirasoftLogServer";
4
-
5
- export class StreamNamirasoftLog implements IStream
6
- {
7
- private queue: (() => Promise<void>)[] = [];
8
- private isProcessing = false;
9
- server: NamirasoftLogServer;
10
- user_id?: string;
11
- log_group_id: string;
12
- getProductID: () => (string | null);
13
- constructor(server: NamirasoftLogServer, log_group_id: string, getProductID: () => (string | null))
14
- {
15
- this.server = server;
16
- this.log_group_id = log_group_id;
17
- this.getProductID = getProductID;
18
- }
19
- write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
20
- {
21
- if (process.env.NAMIRASOFT_STANDALNOE)
22
- return;
23
- let message = [...formated.pre, ...formated.messages, ...formated.post].join("\n");
24
- let body = {
25
- level: log.level.toString(),
26
- log_group_id: this.log_group_id,
27
- product_id: this.getProductID(),
28
- message
29
- };
30
- this.queue.push(async () =>
31
- {
32
- if (this.user_id)
33
- await this.server.log._CreateFor(this.user_id, body);
34
- else
35
- await this.server.log.Create(body);
36
- });
37
- this.processQueue();
38
- }
39
- private async processQueue()
40
- {
41
- if (this.isProcessing)
42
- return;
43
- this.isProcessing = true;
44
- try
45
- {
46
- while (this.queue.length > 0)
47
- {
48
- const job = this.queue.shift();
49
- if (job)
50
- {
51
- try
52
- {
53
- await job();
54
- }
55
- catch (err)
56
- {
57
- }
58
- }
59
- }
60
- } finally
61
- {
62
- this.isProcessing = false;
63
- }
64
- }
1
+ import { IStream } from "./IStream";
2
+ import { Log } from "./Log";
3
+ import { NamirasoftLogServer } from "./NamirasoftLogServer";
4
+
5
+ export class StreamNamirasoftLog implements IStream
6
+ {
7
+ private queue: (() => Promise<void>)[] = [];
8
+ private isProcessing = false;
9
+ server: NamirasoftLogServer;
10
+ user_id?: string;
11
+ log_group_id: string;
12
+ getProductID: () => (string | null);
13
+ constructor(server: NamirasoftLogServer, log_group_id: string, getProductID: () => (string | null))
14
+ {
15
+ this.server = server;
16
+ this.log_group_id = log_group_id;
17
+ this.getProductID = getProductID;
18
+ }
19
+ write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
20
+ {
21
+ if (process.env.NAMIRASOFT_STANDALNOE)
22
+ return;
23
+ let message = [...formated.pre, ...formated.messages, ...formated.post].join("\n");
24
+ let body = {
25
+ level: log.level.toString(),
26
+ log_group_id: this.log_group_id,
27
+ product_id: this.getProductID(),
28
+ message
29
+ };
30
+ this.queue.push(async () =>
31
+ {
32
+ if (this.user_id)
33
+ await this.server.log._CreateFor(this.user_id, body);
34
+ else
35
+ await this.server.log.Create(body);
36
+ });
37
+ this.processQueue();
38
+ }
39
+ private async processQueue()
40
+ {
41
+ if (this.isProcessing)
42
+ return;
43
+ this.isProcessing = true;
44
+ try
45
+ {
46
+ while (this.queue.length > 0)
47
+ {
48
+ const job = this.queue.shift();
49
+ if (job)
50
+ {
51
+ try
52
+ {
53
+ await job();
54
+ }
55
+ catch (err)
56
+ {
57
+ }
58
+ }
59
+ }
60
+ } finally
61
+ {
62
+ this.isProcessing = false;
63
+ }
64
+ }
65
65
  }