@wireio/shared 1.0.2 → 1.0.4

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.
Files changed (61) hide show
  1. package/lib/logging/InternalLogger.d.ts +4 -1
  2. package/lib/logging/InternalLogger.d.ts.map +1 -1
  3. package/lib/logging/InternalLogger.js +19 -4
  4. package/lib/logging/InternalLogger.js.map +1 -1
  5. package/lib/logging/LogRecord.d.ts +7 -4
  6. package/lib/logging/LogRecord.d.ts.map +1 -1
  7. package/lib/logging/Logger.d.ts +8 -4
  8. package/lib/logging/Logger.d.ts.map +1 -1
  9. package/lib/logging/Logger.js +32 -7
  10. package/lib/logging/Logger.js.map +1 -1
  11. package/lib/logging/LoggingManager.d.ts +4 -1
  12. package/lib/logging/LoggingManager.d.ts.map +1 -1
  13. package/lib/logging/LoggingManager.js +7 -0
  14. package/lib/logging/LoggingManager.js.map +1 -1
  15. package/lib/logging/appenders/aws-firehose/AWSFirehoseAppender.d.ts +3 -2
  16. package/lib/logging/appenders/aws-firehose/AWSFirehoseAppender.d.ts.map +1 -1
  17. package/lib/logging/appenders/aws-firehose/AWSFirehoseAppender.js +13 -10
  18. package/lib/logging/appenders/aws-firehose/AWSFirehoseAppender.js.map +1 -1
  19. package/lib/logging/appenders/aws-firehose/AWSFirehoseCredentialManager.d.ts +2 -0
  20. package/lib/logging/appenders/aws-firehose/AWSFirehoseCredentialManager.d.ts.map +1 -1
  21. package/lib/logging/appenders/aws-firehose/AWSFirehoseCredentialManager.js +7 -3
  22. package/lib/logging/appenders/aws-firehose/AWSFirehoseCredentialManager.js.map +1 -1
  23. package/package.json +5 -1
  24. package/src/guards/applyTypeGuardExtras.ts +0 -9
  25. package/src/guards/array.ts +0 -5
  26. package/src/guards/assert.ts +0 -83
  27. package/src/guards/class.ts +0 -56
  28. package/src/guards/guard-tools.ts +0 -78
  29. package/src/guards/index.ts +0 -7
  30. package/src/guards/primitive.ts +0 -77
  31. package/src/guards/types.ts +0 -15
  32. package/src/helpers/Deferred.ts +0 -149
  33. package/src/helpers/index.ts +0 -1
  34. package/src/index.ts +0 -3
  35. package/src/logging/Appender.ts +0 -5
  36. package/src/logging/Formatter.ts +0 -8
  37. package/src/logging/InternalLogger.ts +0 -6
  38. package/src/logging/Level.ts +0 -19
  39. package/src/logging/LogRecord.ts +0 -17
  40. package/src/logging/Logger.ts +0 -222
  41. package/src/logging/LoggingManager.ts +0 -306
  42. package/src/logging/appenders/ConsoleAppender.ts +0 -110
  43. package/src/logging/appenders/DebugAppender.ts +0 -254
  44. package/src/logging/appenders/FileAppender.ts +0 -281
  45. package/src/logging/appenders/aws-firehose/AWSFirehoseAppender.ts +0 -176
  46. package/src/logging/appenders/aws-firehose/AWSFirehoseCredentialManager.ts +0 -132
  47. package/src/logging/appenders/index.ts +0 -3
  48. package/src/logging/context/LogContext.ts +0 -74
  49. package/src/logging/context/LogContextContainer.ts +0 -28
  50. package/src/logging/context/LogContextProvider.ts +0 -43
  51. package/src/logging/context/index.ts +0 -3
  52. package/src/logging/context/providers/node/NodeContextProvider.ts +0 -45
  53. package/src/logging/context/providers/node/index.ts +0 -3
  54. package/src/logging/examples/example-debug-appender.ts +0 -19
  55. package/src/logging/examples/example-file-appender.ts +0 -19
  56. package/src/logging/getLogger.ts +0 -9
  57. package/src/logging/index-node.ts +0 -2
  58. package/src/logging/index.ts +0 -11
  59. package/src/logging/util.ts +0 -6
  60. package/tsconfig.json +0 -9
  61. package/tsconfig.tsbuildinfo +0 -1
@@ -1,43 +0,0 @@
1
- // noinspection JSValidateJSDoc
2
-
3
- import type { LogContext } from "./LogContext"
4
-
5
-
6
-
7
- export interface LogContextProvider {
8
-
9
- /**
10
- * Get current context stack
11
- *
12
- * @returns {any[]}
13
- */
14
- currentContext(): Array<LogContext>
15
-
16
- /**
17
- * Run in context
18
- *
19
- * @param {LogContext} context
20
- * @param {() => Promise<T>} fn
21
- * @returns {Promise<T>}
22
- */
23
- runInContext<T = unknown>(context: LogContext, fn: () => Promise<T>): Promise<T>
24
- }
25
-
26
-
27
- /**
28
- * Dummy/Noop context provider
29
- *
30
- * @type {{currentContext(): Array<LogContext>, runInContext<T=unknown>(context: LogContext, fn: () => Promise<T>): Promise<T>}}
31
- */
32
- export const DefaultLogContextProvider:LogContextProvider = {
33
- currentContext(): Array<LogContext> {
34
- return []
35
- },
36
- runInContext<T = unknown>(context: LogContext, fn: () => Promise<T>): Promise<T> {
37
- if (process.env.NODE_ENV === "development") {
38
- console.warn(`Attempting to use LogContext without any installed provider`)
39
- }
40
-
41
- return fn()
42
- }
43
- }
@@ -1,3 +0,0 @@
1
- export * from "./LogContext.js"
2
- export * from "./LogContextProvider.js"
3
- export * from "./LogContextContainer.js"
@@ -1,45 +0,0 @@
1
- import { AsyncLocalStorage } from "async_hooks"
2
- import { uniq } from "lodash"
3
- import type { LogContext } from "../../LogContext"
4
- import type { LogContextProvider } from "../../LogContextProvider"
5
- import { LogContextContainer } from "../../LogContextContainer.js"
6
-
7
- const contextStorage = new AsyncLocalStorage<Array<LogContext>>()
8
-
9
- function currentContextStore(): Array<LogContext> {
10
- return contextStorage.getStore() ?? []
11
- }
12
-
13
- class NodeContextProvider implements LogContextProvider {
14
-
15
-
16
- /**
17
- * Get current context stack
18
- *
19
- * @returns {any[]}
20
- */
21
- currentContext(): Array<LogContext> {
22
- return currentContextStore() ?? []
23
- }
24
-
25
- /**
26
- * Run in context
27
- *
28
- * @param {LogContext} context
29
- * @param {() => Promise<T>} fn
30
- * @returns {Promise<T>}
31
- */
32
- runInContext<T = unknown>(
33
- context: LogContext,
34
- fn: () => Promise<T>
35
- ): Promise<T> {
36
- const contexts = currentContextStore()
37
- return contextStorage.run<Promise<T>, []>(uniq([...contexts, context]), fn)
38
- }
39
- }
40
-
41
- const instance = new NodeContextProvider()
42
-
43
- LogContextContainer.setProvider(instance)
44
-
45
- export {}
@@ -1,3 +0,0 @@
1
- import "./NodeContextProvider.js"
2
-
3
- export {}
@@ -1,19 +0,0 @@
1
- import { getLogger } from "../getLogger.js"
2
- import { LevelNames } from "../Level.js"
3
- import { getLoggingManager } from "../LoggingManager.js"
4
-
5
-
6
- getLoggingManager().configure({
7
- // Default appenders list is [ConsoleAppender],
8
- // so the following is not needed and only
9
- // remains as an example:
10
- //
11
- // appenders: [new ConsoleAppender()],
12
- rootLevel: "trace"
13
- })
14
-
15
- const log = getLogger(__filename)
16
-
17
- LevelNames.forEach((name) =>
18
- log[name].call(log, `example %s`, name)
19
- )
@@ -1,19 +0,0 @@
1
- import { FileAppender } from "../appenders/FileAppender.js"
2
- import { getLogger } from "../getLogger.js"
3
- import { LevelNames } from "../Level.js"
4
- import { getLoggingManager } from "../LoggingManager.js"
5
-
6
- async function run() {
7
- const manager = getLoggingManager()
8
- const fileAppender = new FileAppender({
9
- enableRolling: true,
10
- maxFiles: 4,
11
- maxSize: 20480
12
- })
13
- manager.setAppenders(fileAppender).setRootLevel("trace")
14
-
15
- const log = getLogger(__filename)
16
- await fileAppender.close()
17
- }
18
-
19
- run().catch((err) => console.error(`failed`, err))
@@ -1,9 +0,0 @@
1
- import type { Logger, LoggerOptions } from "./Logger"
2
- import { getLoggingManager } from "./LoggingManager.js"
3
-
4
- export function getLogger(
5
- category: string,
6
- options: Partial<LoggerOptions> = {}
7
- ): Logger {
8
- return getLoggingManager().getLogger(category, options)
9
- }
@@ -1,2 +0,0 @@
1
- export * from "./index.js"
2
- export * from "./appenders/FileAppender.js"
@@ -1,11 +0,0 @@
1
- export * from "./Appender.js"
2
- export * from "./Formatter.js"
3
- export * from "./Level.js"
4
- export * from "./LogRecord.js"
5
- export * from "./Logger.js"
6
- export * from "./LoggingManager.js"
7
- export * from "./appenders/index.js"
8
- export * from "./getLogger.js"
9
- export * from "./util.js"
10
- export * from "./context/index.js"
11
-
@@ -1,6 +0,0 @@
1
- import { isString } from "../guards/primitive.js"
2
- import { LevelKind, LevelNames } from "./Level.js"
3
-
4
- export function isLogLevelKind(o: any): o is LevelKind {
5
- return isString(o) && LevelNames.includes(o?.toLowerCase?.() as any)
6
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../etc/tsconfig/tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "lib"
6
- },
7
- "include": ["src"],
8
-
9
- }