@node-ts/logger-core
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -8,1 +8,2 @@ export * from './logger'; | ||
export * from './bind-logger'; | ||
export * from './auto-bind-logger'; |
@@ -9,2 +9,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./bind-logger"), exports); | ||
tslib_1.__exportStar(require("./auto-bind-logger"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@node-ts/logger-core", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "Defines a logging adapter contract between consumers and implementations", | ||
@@ -38,3 +38,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "d3cf9fba35f5f1446c6fea69c31881ecc86c0049" | ||
"gitHead": "d6edb3920787699ba22c48d2770ee77865922b1f" | ||
} |
@@ -156,2 +156,3 @@ # @node-ts/logger-core | ||
import { MyService } from './my-service' | ||
import { MyOtherService } from './my-other-service' | ||
@@ -162,3 +163,9 @@ export class ApplicationContainer extends Container { | ||
super (bind => { | ||
bind(MyService).toSelf() | ||
// Create and bind a logger named 'MyService' | ||
bindLogger(bind, MyService) | ||
bind(MyOtherService).toSelf() | ||
// Create and bind a logger named 'MyOtherService' | ||
bindLogger(bind, MyOtherService) | ||
}) | ||
@@ -172,1 +179,30 @@ } | ||
``` | ||
## Automatically binding named loggers | ||
In the above example, a named logger is explicitly defined for each target it's to be injected into. To automatically bind all usages of `LOGGER_SYMBOLS.Logger` to a named logger for that target type, use `autoBindLogger()` instead: | ||
```typescript | ||
// application-container.ts | ||
import { Container } from 'inversify' | ||
import { LoggerModule, autoBindLogger } from '@node-ts/logger-core' | ||
import { MyService } from './my-service' | ||
import { MyOtherService } from './my-other-service' | ||
export class ApplicationContainer extends Container { | ||
constructor () { | ||
super (bind => { | ||
bind(MyService).toSelf() | ||
bind(MyOtherService).toSelf() | ||
// Creates new named loggers for all targets in the container, including the above services | ||
autoBindLogger(bind) | ||
}) | ||
} | ||
start (): void { | ||
this.load(new LoggerModule()) | ||
} | ||
} | ||
``` |
@@ -8,1 +8,2 @@ export * from './logger' | ||
export * from './bind-logger' | ||
export * from './auto-bind-logger' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37100
49
565
206