Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logger): fix logger storage issue for key already exists #10

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.3.7",
"version": "0.3.8",
"changelog": true,
"changelogPreset": {
"name": "conventionalcommits",
Expand Down
4 changes: 2 additions & 2 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-builder",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -44,7 +44,7 @@
"webpack": "^5.75.0"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-shared": "^0.3.8",
"yargs": "17.6.2"
}
}
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-cli",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -31,7 +31,7 @@
"@types/node-fetch": "2.6.3"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-shared": "^0.3.8",
"commander": "10.0.1",
"fs-extra": "11.1.1",
"node-fetch": "^2.6.9",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-core",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -25,8 +25,8 @@
"@ringcentral/mfe-shared": "^0.1.0"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-transport": "^0.3.7"
"@ringcentral/mfe-shared": "^0.3.8",
"@ringcentral/mfe-transport": "^0.3.8"
},
"bugs": {
"url": "https://github.com/ringcentral/ringcentral-mfe/issues"
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-logger",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -25,7 +25,7 @@
"@ringcentral/mfe-shared": "^0.1.0"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-shared": "^0.3.8",
"@roarr/browser-log-writer": "1.3.0",
"dexie": "3.2.4",
"file-saver": "2.0.5",
Expand Down
12 changes: 11 additions & 1 deletion packages/logger/src/transports/storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
/* eslint-disable consistent-return */
import { getLogLevelName, Message } from 'roarr';
import { global } from '@ringcentral/mfe-shared';
Expand Down Expand Up @@ -219,8 +220,17 @@ export class StorageTransport implements ITransport {

protected _savingLogs = new Set<Logs>();

protected _saveLogs(data: Logs) {
protected async _checkTimeKey(time: number): Promise<number> {
const count = await this._table?.where('time').equals(time).count();
if (count) {
return this._checkTimeKey(time + 1);
}
return time;
}

protected async _saveLogs(data: Logs) {
this._savingLogs.add(data);
data.time = await this._checkTimeKey(data.time);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so from now every time will reget value from DB storage

what is the time be use?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這個time的用途是什麼?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "time" refers to the initialization time of each log entry. It means that every time a write is made to the DB, this "time" will be set in memory as the value for a new log entry using the current time.

It's different from a session, which is a value for a single runtime.

The "time" field here is used for index querying.

const savingLogsPromise = this._table?.add(data).then(() => {
this._savingLogs.delete(data);
if (this.savingLogsPromise === savingLogsPromise) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-react",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -39,7 +39,7 @@
"react": "^17.0.2"
},
"dependencies": {
"@ringcentral/mfe-core": "^0.3.7"
"@ringcentral/mfe-core": "^0.3.8"
},
"devDependencies": {
"@testing-library/react": "^12.1.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/sentry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-sentry",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -39,7 +39,7 @@
"@ringcentral/mfe-shared": "^0.1.0"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-shared": "^0.3.8",
"@sentry/browser": "^7.99.0",
"@sentry/tracing": "^7.99.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/service-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-service-worker",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "index.js",
"module": "index.mjs",
Expand Down Expand Up @@ -46,7 +46,7 @@
"webpack": "^5.75.0"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-shared": "^0.3.8",
"crypto": "^1.0.1",
"ts-md5": "1.3.1",
"workbox-window": "6.5.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-shared",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/transport/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ringcentral/mfe-transport",
"version": "0.3.7",
"version": "0.3.8",
"description": "A micro frontends framework for building Web applications",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -39,7 +39,7 @@
"data-transport": "^4.3.5"
},
"dependencies": {
"@ringcentral/mfe-shared": "^0.3.7",
"@ringcentral/mfe-shared": "^0.3.8",
"data-transport": "^4.3.5"
}
}
Loading