@twin.org/logging-connector-console 0.0.1-next.6 → 0.0.1-next.8

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.
@@ -51,7 +51,6 @@ class ConsoleLoggingConnector {
51
51
  /**
52
52
  * Create a new instance of ConsoleLoggingConnector.
53
53
  * @param options The options for the logging connector.
54
- * @param options.config The configuration for the logging connector.
55
54
  */
56
55
  constructor(options) {
57
56
  this._levels = options?.config?.levels ?? ["debug", "info", "warn", "error", "trace"];
@@ -66,14 +65,17 @@ class ConsoleLoggingConnector {
66
65
  async log(logEntry) {
67
66
  core.Guards.object(this.CLASS_NAME, "logEntry", logEntry);
68
67
  if (this._levels.includes(logEntry.level)) {
69
- if (!this._hideGroups) {
70
- this.handleGroup(logEntry.source);
71
- }
72
68
  logEntry.ts ??= Date.now();
73
69
  const params = [
74
70
  this.colorize(logEntry.level.toUpperCase(), logEntry.level === "error" ? "red" : "green"),
75
71
  this.colorize(`[${new Date(logEntry.ts).toISOString()}]`, "magenta")
76
72
  ];
73
+ if (!this._hideGroups) {
74
+ this.handleGroup(logEntry.source);
75
+ }
76
+ else {
77
+ params.push(this.colorize(logEntry.source, "blue"));
78
+ }
77
79
  let message = logEntry.message;
78
80
  let data = logEntry.data;
79
81
  if (this._translateMessages) {
@@ -49,7 +49,6 @@ class ConsoleLoggingConnector {
49
49
  /**
50
50
  * Create a new instance of ConsoleLoggingConnector.
51
51
  * @param options The options for the logging connector.
52
- * @param options.config The configuration for the logging connector.
53
52
  */
54
53
  constructor(options) {
55
54
  this._levels = options?.config?.levels ?? ["debug", "info", "warn", "error", "trace"];
@@ -64,14 +63,17 @@ class ConsoleLoggingConnector {
64
63
  async log(logEntry) {
65
64
  Guards.object(this.CLASS_NAME, "logEntry", logEntry);
66
65
  if (this._levels.includes(logEntry.level)) {
67
- if (!this._hideGroups) {
68
- this.handleGroup(logEntry.source);
69
- }
70
66
  logEntry.ts ??= Date.now();
71
67
  const params = [
72
68
  this.colorize(logEntry.level.toUpperCase(), logEntry.level === "error" ? "red" : "green"),
73
69
  this.colorize(`[${new Date(logEntry.ts).toISOString()}]`, "magenta")
74
70
  ];
71
+ if (!this._hideGroups) {
72
+ this.handleGroup(logEntry.source);
73
+ }
74
+ else {
75
+ params.push(this.colorize(logEntry.source, "blue"));
76
+ }
75
77
  let message = logEntry.message;
76
78
  let data = logEntry.data;
77
79
  if (this._translateMessages) {
@@ -1,6 +1,6 @@
1
1
  import type { EntityCondition, SortDirection } from "@twin.org/entity";
2
2
  import { type ILogEntry, type ILoggingConnector } from "@twin.org/logging-models";
3
- import type { IConsoleLoggingConnectorConfig } from "./models/IConsoleLoggingConnectorConfig";
3
+ import type { IConsoleLoggingConnectorConstructorOptions } from "./models/IConsoleLoggingConnectorConstructorOptions";
4
4
  /**
5
5
  * Class for performing logging operations in the console.
6
6
  */
@@ -16,11 +16,8 @@ export declare class ConsoleLoggingConnector implements ILoggingConnector {
16
16
  /**
17
17
  * Create a new instance of ConsoleLoggingConnector.
18
18
  * @param options The options for the logging connector.
19
- * @param options.config The configuration for the logging connector.
20
19
  */
21
- constructor(options?: {
22
- config?: IConsoleLoggingConnectorConfig;
23
- });
20
+ constructor(options?: IConsoleLoggingConnectorConstructorOptions);
24
21
  /**
25
22
  * Log an entry to the connector.
26
23
  * @param logEntry The entry to log.
@@ -1,2 +1,3 @@
1
1
  export * from "./consoleLoggingConnector";
2
2
  export * from "./models/IConsoleLoggingConnectorConfig";
3
+ export * from "./models/IConsoleLoggingConnectorConstructorOptions";
@@ -0,0 +1,10 @@
1
+ import type { IConsoleLoggingConnectorConfig } from "./IConsoleLoggingConnectorConfig";
2
+ /**
3
+ * Options for the console logging connector constructor.
4
+ */
5
+ export interface IConsoleLoggingConnectorConstructorOptions {
6
+ /**
7
+ * The configuration for the console logging connector.
8
+ */
9
+ config?: IConsoleLoggingConnectorConfig;
10
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/logging-connector-console - Changelog
2
2
 
3
- ## v0.0.1-next.6
3
+ ## v0.0.1-next.8
4
4
 
5
5
  - Initial Release
@@ -16,13 +16,11 @@ Create a new instance of ConsoleLoggingConnector.
16
16
 
17
17
  #### Parameters
18
18
 
19
- **options?**
19
+ ##### options?
20
20
 
21
- The options for the logging connector.
22
-
23
- • **options.config?**: [`IConsoleLoggingConnectorConfig`](../interfaces/IConsoleLoggingConnectorConfig.md)
21
+ [`IConsoleLoggingConnectorConstructorOptions`](../interfaces/IConsoleLoggingConnectorConstructorOptions.md)
24
22
 
25
- The configuration for the logging connector.
23
+ The options for the logging connector.
26
24
 
27
25
  #### Returns
28
26
 
@@ -58,7 +56,9 @@ Log an entry to the connector.
58
56
 
59
57
  #### Parameters
60
58
 
61
- **logEntry**: `ILogEntry`
59
+ ##### logEntry
60
+
61
+ `ILogEntry`
62
62
 
63
63
  The entry to log.
64
64
 
@@ -76,51 +76,49 @@ Nothing.
76
76
 
77
77
  ### query()
78
78
 
79
- > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
79
+ > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<\{ `entities`: `Partial`\<`ILogEntry`\>[]; `cursor`: `string`; \}\>
80
80
 
81
81
  Query the log entries.
82
82
 
83
83
  #### Parameters
84
84
 
85
- **conditions?**: `EntityCondition`\<`ILogEntry`\>
85
+ ##### conditions?
86
+
87
+ `EntityCondition`\<`ILogEntry`\>
86
88
 
87
89
  The conditions to match for the entities.
88
90
 
89
- **sortProperties?**: `object`[]
91
+ ##### sortProperties?
92
+
93
+ `object`[]
90
94
 
91
95
  The optional sort order.
92
96
 
93
- **properties?**: keyof `ILogEntry`[]
97
+ ##### properties?
98
+
99
+ keyof `ILogEntry`[]
94
100
 
95
101
  The optional keys to return, defaults to all.
96
102
 
97
- **cursor?**: `string`
103
+ ##### cursor?
104
+
105
+ `string`
98
106
 
99
107
  The cursor to request the next page of entities.
100
108
 
101
- **pageSize?**: `number`
109
+ ##### pageSize?
110
+
111
+ `number`
102
112
 
103
113
  The maximum number of entities in a page.
104
114
 
105
115
  #### Returns
106
116
 
107
- `Promise`\<`object`\>
117
+ `Promise`\<\{ `entities`: `Partial`\<`ILogEntry`\>[]; `cursor`: `string`; \}\>
108
118
 
109
119
  All the entities for the storage matching the conditions,
110
120
  and a cursor which can be used to request more entities.
111
121
 
112
- ##### entities
113
-
114
- > **entities**: `Partial`\<`ILogEntry`\>[]
115
-
116
- The entities, which can be partial if a limited keys list was provided.
117
-
118
- ##### cursor?
119
-
120
- > `optional` **cursor**: `string`
121
-
122
- An optional cursor, when defined can be used to call find to get more entities.
123
-
124
122
  #### Throws
125
123
 
126
124
  NotImplementedError if the implementation does not support retrieval.
@@ -7,3 +7,4 @@
7
7
  ## Interfaces
8
8
 
9
9
  - [IConsoleLoggingConnectorConfig](interfaces/IConsoleLoggingConnectorConfig.md)
10
+ - [IConsoleLoggingConnectorConstructorOptions](interfaces/IConsoleLoggingConnectorConstructorOptions.md)
@@ -0,0 +1,11 @@
1
+ # Interface: IConsoleLoggingConnectorConstructorOptions
2
+
3
+ Options for the console logging connector constructor.
4
+
5
+ ## Properties
6
+
7
+ ### config?
8
+
9
+ > `optional` **config**: [`IConsoleLoggingConnectorConfig`](IConsoleLoggingConnectorConfig.md)
10
+
11
+ The configuration for the console logging connector.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/logging-connector-console",
3
- "version": "0.0.1-next.6",
3
+ "version": "0.0.1-next.8",
4
4
  "description": "Logging connector implementation using the console",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
- "@twin.org/logging-models": "0.0.1-next.6",
18
+ "@twin.org/logging-models": "0.0.1-next.8",
19
19
  "@twin.org/nameof": "next"
20
20
  },
21
21
  "main": "./dist/cjs/index.cjs",