@darksheep/logger 1.0.2 → 1.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.3](https://github.com/DarkSheepSoftware/node-packages/compare/logger-v1.0.2...logger-v1.0.3) (2024-08-12)
4
+
5
+
6
+ ### 🧹 Chores
7
+
8
+ * update env access ([#309](https://github.com/DarkSheepSoftware/node-packages/issues/309)) ([c0bb192](https://github.com/DarkSheepSoftware/node-packages/commit/c0bb192deb0d016f3893e14ab6270461d5f5b07d))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @darksheep/environment bumped from 3.0.5 to 3.0.6
16
+
3
17
  ## [1.0.2](https://github.com/DarkSheepSoftware/node-packages/compare/logger-v1.0.1...logger-v1.0.2) (2024-08-01)
4
18
 
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksheep/logger",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Logging your stuff to where ever you want it",
5
5
  "license": "UNLICENCED",
6
6
  "type": "module",
@@ -24,16 +24,17 @@
24
24
  "test:watch": "node --watch --test src/**/*.test.js"
25
25
  },
26
26
  "dependencies": {
27
+ "@darksheep/environment": "3.0.6",
27
28
  "deepmerge-ts": "7.1.0",
28
29
  "stacktrace-parser": "0.1.10",
29
30
  "traverse": "0.6.9"
30
31
  },
31
32
  "devDependencies": {
32
- "@darksheep/eslint": "~5.1.0",
33
+ "@darksheep/eslint": "~5.3.0",
33
34
  "@types/eslint": "~9.6.0",
34
35
  "@types/node": "~20.14.0",
35
36
  "@types/traverse": "~0.6.33",
36
- "eslint": "~9.8.0",
37
+ "eslint": "~9.9.0",
37
38
  "nock": "~13.5.0",
38
39
  "typescript": "~5.5.0",
39
40
  "zod": "~3.23.0"
@@ -1,61 +1,32 @@
1
+ import { getTypedEnv } from '@darksheep/environment';
2
+
1
3
  import { parseFilters } from './parse-filters.js';
2
4
  import { parseLogLevel } from './parse-log-level.js';
3
5
 
4
- /**
5
- * @param {undefined | string} input The env var to check for booleaness
6
- * @param {boolean} fallback The fallback bool
7
- * @returns {boolean}
8
- */
9
- function parseBoolean(input, fallback) {
10
- if (input === 'true' || input === '1') {
11
- return true;
12
- }
13
-
14
- if (input === 'false' || input === '0') {
15
- return false;
16
- }
17
-
18
- return fallback;
19
- }
20
-
21
- /**
22
- * @param {undefined | string} input The env var to check to see if its an int
23
- * @param {number} fallback The fallback number
24
- * @returns {number}
25
- */
26
- function parseInt(input, fallback) {
27
- if (typeof input === 'string') {
28
- const number = Number.parseInt(input, 10);
29
-
30
- if (Number.isNaN(number) === false) {
31
- return number;
32
- }
33
- }
34
-
35
- return fallback;
36
- }
37
-
38
- const isDevelopment = process.env.NODE_ENV === 'development';
39
- const isTesting = process.env.NODE_ENV === 'test';
40
- const isProduction = process.env.NODE_ENV === 'production';
41
-
42
- const logLevel = parseLogLevel(
43
- process.env.LOG_LEVEL,
44
- process.env.NODE_ENV,
45
- );
46
- const logFilters = parseFilters(process.env.LOG_FILTERS, [ /.*/ ]);
47
- const secretFilters = parseFilters(process.env.LOG_SECRETS);
48
- const includeCallsite = parseBoolean(process.env.LOG_CALLSITES, false);
49
- const stringMaxLength = parseInt(process.env.LOG_MAX_LENGTH, 1024);
6
+ const {
7
+ NODE_ENV = 'production',
8
+ LOG_LEVEL,
9
+ LOG_FILTERS,
10
+ LOG_SECRETS,
11
+ LOG_CALLSITES = false,
12
+ LOG_MAX_LENGTH = 1024,
13
+ } = getTypedEnv({
14
+ NODE_ENV: '?string',
15
+ LOG_LEVEL: '?string',
16
+ LOG_FILTERS: '?string',
17
+ LOG_SECRETS: '?string',
18
+ LOG_CALLSITES: '?boolean',
19
+ LOG_MAX_LENGTH: '?number',
20
+ });
50
21
 
51
22
  export const environment = {
52
- isDevelopment,
53
- isTesting,
54
- isProduction,
55
-
56
- logLevel,
57
- logFilters,
58
- secretFilters,
59
- includeCallsite,
60
- stringMaxLength,
23
+ isDevelopment: NODE_ENV === 'development',
24
+ isTesting: NODE_ENV === 'test',
25
+ isProduction: NODE_ENV === 'production',
26
+
27
+ logLevel: parseLogLevel(LOG_LEVEL, NODE_ENV),
28
+ logFilters: parseFilters(LOG_FILTERS, [ /.*/ ]),
29
+ secretFilters: parseFilters(LOG_SECRETS),
30
+ includeCallsite: LOG_CALLSITES,
31
+ stringMaxLength: LOG_MAX_LENGTH,
61
32
  };
@@ -1,25 +1,19 @@
1
1
  export namespace environment {
2
- export { isDevelopment };
3
- export { isTesting };
4
- export { isProduction };
5
- export { logLevel };
6
- export { logFilters };
7
- export { secretFilters };
8
- export { includeCallsite };
9
- export { stringMaxLength };
2
+ export let isDevelopment: boolean;
3
+ export let isTesting: boolean;
4
+ export let isProduction: boolean;
5
+ export let logLevel: import("./log-types.js").LogLevel;
6
+ export let logFilters: {
7
+ allowed: RegExp[];
8
+ blocked: RegExp[];
9
+ };
10
+ export let secretFilters: {
11
+ allowed: RegExp[];
12
+ blocked: RegExp[];
13
+ };
14
+ export { LOG_CALLSITES as includeCallsite };
15
+ export { LOG_MAX_LENGTH as stringMaxLength };
10
16
  }
11
- declare const isDevelopment: boolean;
12
- declare const isTesting: boolean;
13
- declare const isProduction: boolean;
14
- declare const logLevel: import("./log-types.js").LogLevel;
15
- declare const logFilters: {
16
- allowed: RegExp[];
17
- blocked: RegExp[];
18
- };
19
- declare const secretFilters: {
20
- allowed: RegExp[];
21
- blocked: RegExp[];
22
- };
23
- declare const includeCallsite: boolean;
24
- declare const stringMaxLength: number;
17
+ declare const LOG_CALLSITES: boolean;
18
+ declare const LOG_MAX_LENGTH: number;
25
19
  export {};