@4players/odin-common 2.4.8 → 2.4.9

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.
@@ -18,24 +18,18 @@ class OdinError extends Error {
18
18
  }
19
19
  }
20
20
  exports.OdinError = OdinError;
21
- function log(options, filters = { projects: [], kind: [] }, ...args) {
22
- if (options.project in filters.projects) {
23
- if (options.kind in filters.kind) {
24
- let logMessage = '';
25
- const date = new Date();
26
- const hours = date.getHours();
27
- const minutes = date.getMinutes();
28
- const seconds = date.getSeconds();
29
- if (options === null || options === void 0 ? void 0 : options.project) {
30
- logMessage = `ODIN ${options === null || options === void 0 ? void 0 : options.project} | ${options === null || options === void 0 ? void 0 : options.kind}`;
31
- }
32
- logMessage += ` at ${options === null || options === void 0 ? void 0 : options.project} ${hours}:${minutes}:${seconds}\n`;
33
- if (options.type) {
34
- console[options.type](logMessage, ...args);
35
- }
36
- else {
37
- console.log(logMessage, ...args);
38
- }
21
+ function log(options, filters = { filters: [] }, args) {
22
+ if (filters.filters.includes(options.kind)) {
23
+ let logMessage = '';
24
+ const date = new Date();
25
+ const hours = date.getHours();
26
+ const minutes = date.getMinutes();
27
+ const seconds = date.getSeconds();
28
+ if (options === null || options === void 0 ? void 0 : options.project) {
29
+ logMessage = `ODIN at ${hours}:${minutes}:${seconds} in ${options === null || options === void 0 ? void 0 : options.project}(${options === null || options === void 0 ? void 0 : options.kind})\n`;
30
+ }
31
+ if (options.type) {
32
+ console[options.type](logMessage, ...args);
39
33
  }
40
34
  }
41
35
  }
@@ -14,24 +14,18 @@ export class OdinError extends Error {
14
14
  this.message += `${message}\n`;
15
15
  }
16
16
  }
17
- export function log(options, filters = { projects: [], kind: [] }, ...args) {
18
- if (options.project in filters.projects) {
19
- if (options.kind in filters.kind) {
20
- let logMessage = '';
21
- const date = new Date();
22
- const hours = date.getHours();
23
- const minutes = date.getMinutes();
24
- const seconds = date.getSeconds();
25
- if (options === null || options === void 0 ? void 0 : options.project) {
26
- logMessage = `ODIN ${options === null || options === void 0 ? void 0 : options.project} | ${options === null || options === void 0 ? void 0 : options.kind}`;
27
- }
28
- logMessage += ` at ${options === null || options === void 0 ? void 0 : options.project} ${hours}:${minutes}:${seconds}\n`;
29
- if (options.type) {
30
- console[options.type](logMessage, ...args);
31
- }
32
- else {
33
- console.log(logMessage, ...args);
34
- }
17
+ export function log(options, filters = { filters: [] }, args) {
18
+ if (filters.filters.includes(options.kind)) {
19
+ let logMessage = '';
20
+ const date = new Date();
21
+ const hours = date.getHours();
22
+ const minutes = date.getMinutes();
23
+ const seconds = date.getSeconds();
24
+ if (options === null || options === void 0 ? void 0 : options.project) {
25
+ logMessage = `ODIN at ${hours}:${minutes}:${seconds} in ${options === null || options === void 0 ? void 0 : options.project}(${options === null || options === void 0 ? void 0 : options.kind})\n`;
26
+ }
27
+ if (options.type) {
28
+ console[options.type](logMessage, ...args);
35
29
  }
36
30
  }
37
31
  }
@@ -5,15 +5,14 @@ export type LogOptions = {
5
5
  type?: LogType;
6
6
  };
7
7
  export type LogFilters = {
8
- projects: string[];
9
- kind: string[];
8
+ filters: string[];
10
9
  };
11
10
  export declare class OdinError extends Error {
12
11
  message: string;
13
12
  readonly name = "OdinError";
14
13
  constructor(message?: string, options?: LogOptions);
15
14
  }
16
- export declare function log(options: LogOptions, filters?: LogFilters, ...args: any[]): void;
15
+ export declare function log(options: LogOptions, filters: LogFilters | undefined, args: any[]): void;
17
16
  export declare class Logger {
18
17
  readonly project: string;
19
18
  filters: LogFilters;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-common",
3
- "version": "2.4.8",
3
+ "version": "2.4.9",
4
4
  "description": "A collection of commonly used type definitions and utility functions across ODIN web projects",
5
5
  "author": "Josho Bleicker <josho.bleicker@4players.io> (https://www.4players.io)",
6
6
  "homepage": "https://www.4players.io",