@furystack/core
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -15,3 +15,2 @@ /// <reference types="node" /> | ||
remove(key: T[this['primaryKey']]): Promise<void>; | ||
readonly logScope: string; | ||
private cache; | ||
@@ -31,2 +30,3 @@ tick: NodeJS.Timeout; | ||
private writeFile; | ||
private logger; | ||
constructor(options: { | ||
@@ -33,0 +33,0 @@ fileName: string; |
@@ -12,3 +12,2 @@ "use strict"; | ||
this.options = options; | ||
this.logScope = '@furystack/core/' + this.constructor.name; | ||
this.cache = new Map(); | ||
@@ -37,2 +36,3 @@ this.tick = setInterval(() => this.saveChanges(), this.options.tickMs || 5000); | ||
this.model = options.model; | ||
this.logger = options.logger.withScope('@furystack/core/' + this.constructor.name); | ||
options.readFile && (this.readFile = options.readFile); | ||
@@ -42,4 +42,3 @@ options.writeFile && (this.writeFile = options.writeFile); | ||
this.watcher = fs_1.watch(this.options.fileName, { encoding: 'buffer' }, () => { | ||
this.options.logger.verbose({ | ||
scope: this.logScope, | ||
this.logger.verbose({ | ||
message: `The file '${this.options.fileName}' has been changed, reloading data...`, | ||
@@ -93,4 +92,3 @@ }); | ||
this.hasChanges = false; | ||
this.options.logger.information({ | ||
scope: this.logScope, | ||
this.logger.information({ | ||
message: `Store '${this.options.fileName}' has been updated with the latest changes.`, | ||
@@ -101,4 +99,3 @@ data: { values }, | ||
catch (e) { | ||
this.options.logger.error({ | ||
scope: this.logScope, | ||
this.logger.error({ | ||
message: `Error saving changed data to '${this.options.fileName}'.`, | ||
@@ -113,4 +110,3 @@ data: { error: e }, | ||
async dispose() { | ||
this.options.logger.information({ | ||
scope: this.logScope, | ||
this.logger.information({ | ||
message: `Disposing FileStore: '${this.options.fileName}'`, | ||
@@ -142,4 +138,3 @@ }); | ||
catch (e) { | ||
this.options.logger.error({ | ||
scope: this.logScope, | ||
this.logger.error({ | ||
message: `Error loading data into store from '${this.options.fileName}'.`, | ||
@@ -146,0 +141,0 @@ data: e, |
@@ -13,4 +13,5 @@ import { Constructable, Injector } from '@furystack/inject'; | ||
addStore<T>(store: IPhysicalStore<T, DefaultFilter<T>>): this; | ||
private logger; | ||
constructor(injector: Injector); | ||
} | ||
//# sourceMappingURL=StoreManager.d.ts.map |
@@ -12,2 +12,3 @@ "use strict"; | ||
this.stores = new Map(); | ||
this.logger = injector.logger.withScope('@furystack/core/' + this.constructor.name); | ||
} | ||
@@ -22,4 +23,3 @@ async dispose() { | ||
if (!instance) { | ||
this.injector.logger.warning({ | ||
scope: '@furystack/core/StoreManager', | ||
this.logger.warning({ | ||
message: `Store not found for '${model.name}'`, | ||
@@ -26,0 +26,0 @@ }); |
{ | ||
"name": "@furystack/core", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Core FuryStack package", | ||
@@ -59,3 +59,3 @@ "main": "dist/index.js", | ||
"@furystack/inject": "^3.0.1", | ||
"@furystack/logging": "^1.0.0", | ||
"@furystack/logging": "^1.1.0", | ||
"@sensenet/client-utils": "^1.5.1", | ||
@@ -78,3 +78,3 @@ "semaphore-async-await": "1.5.1" | ||
"typings": "./dist/index.d.ts", | ||
"gitHead": "2fa8429190fca702d037ea9da26cdc9ded16a8de" | ||
"gitHead": "f1b889fbd2faf4fe923af433e4a3bb9d0d3f71bb" | ||
} |
import { Constructable } from '@furystack/inject' | ||
import { ILogger } from '@furystack/logging' | ||
import { ILogger, ScopedLogger } from '@furystack/logging' | ||
import { FSWatcher, readFile as nodeReadFile, watch, writeFile as nodeWriteFile } from 'fs' | ||
@@ -20,3 +20,2 @@ import Semaphore from 'semaphore-async-await' | ||
} | ||
public readonly logScope: string = '@furystack/core/' + this.constructor.name | ||
private cache: Map<T[this['primaryKey']], T> = new Map() | ||
@@ -79,4 +78,3 @@ public tick = setInterval(() => this.saveChanges(), this.options.tickMs || 5000) | ||
this.hasChanges = false | ||
this.options.logger.information({ | ||
scope: this.logScope, | ||
this.logger.information({ | ||
message: `Store '${this.options.fileName}' has been updated with the latest changes.`, | ||
@@ -86,4 +84,3 @@ data: { values }, | ||
} catch (e) { | ||
this.options.logger.error({ | ||
scope: this.logScope, | ||
this.logger.error({ | ||
message: `Error saving changed data to '${this.options.fileName}'.`, | ||
@@ -98,4 +95,3 @@ data: { error: e }, | ||
public async dispose() { | ||
this.options.logger.information({ | ||
scope: this.logScope, | ||
this.logger.information({ | ||
message: `Disposing FileStore: '${this.options.fileName}'`, | ||
@@ -126,4 +122,3 @@ }) | ||
} catch (e) { | ||
this.options.logger.error({ | ||
scope: this.logScope, | ||
this.logger.error({ | ||
message: `Error loading data into store from '${this.options.fileName}'.`, | ||
@@ -145,2 +140,4 @@ data: e, | ||
private logger: ScopedLogger | ||
constructor( | ||
@@ -159,2 +156,3 @@ private readonly options: { | ||
this.model = options.model | ||
this.logger = options.logger.withScope('@furystack/core/' + this.constructor.name) | ||
options.readFile && (this.readFile = options.readFile) | ||
@@ -165,4 +163,3 @@ options.writeFile && (this.writeFile = options.writeFile) | ||
this.watcher = watch(this.options.fileName, { encoding: 'buffer' }, () => { | ||
this.options.logger.verbose({ | ||
scope: this.logScope, | ||
this.logger.verbose({ | ||
message: `The file '${this.options.fileName}' has been changed, reloading data...`, | ||
@@ -169,0 +166,0 @@ }) |
import { Constructable, Injectable, Injector } from '@furystack/inject' | ||
import { ScopedLogger } from '@furystack/logging' | ||
import { Disposable } from '@sensenet/client-utils' | ||
@@ -20,4 +21,3 @@ import { DefaultFilter, IPhysicalStore } from './Models/IPhysicalStore' | ||
if (!instance) { | ||
this.injector.logger.warning({ | ||
scope: '@furystack/core/StoreManager', | ||
this.logger.warning({ | ||
message: `Store not found for '${model.name}'`, | ||
@@ -36,3 +36,7 @@ }) | ||
constructor(public injector: Injector) {} | ||
private logger: ScopedLogger | ||
constructor(public injector: Injector) { | ||
this.logger = injector.logger.withScope('@furystack/core/' + this.constructor.name) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
62388
809
Updated@furystack/logging@^1.1.0