There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor(core): use debug log replace console when command registry (#5237)
Joooye_34c1bb4670136f
diff --git a/packages/common/infra/package.json b/packages/common/infra/package.jsonindex 5852cffc6e..f3696205f0 100644--- a/packages/common/infra/package.json+++ b/packages/common/infra/package.json@@ -54,6 +54,7 @@"dev": "vite build --watch"},"dependencies": {+ "@affine/debug": "workspace:*","@affine/env": "workspace:*","@affine/sdk": "workspace:*","@blocksuite/blocks": "0.11.0-nightly-202312070955-2b5bb47",diff --git a/packages/common/infra/src/command/registry.ts b/packages/common/infra/src/command/registry.tsindex 11443a93e1..c77292d4c3 100644--- a/packages/common/infra/src/command/registry.ts+++ b/packages/common/infra/src/command/registry.ts@@ -1,3 +1,4 @@+import { DebugLogger } from '@affine/debug';// @ts-expect-error upstream type is wrongimport { tinykeys } from 'tinykeys';@@ -7,12 +8,14 @@ import {createAffineCommand,} from './command';+const commandLogger = new DebugLogger('command:registry');+export const AffineCommandRegistry = new (class {readonly commands: Map<string, AffineCommand> = new Map();register(options: AffineCommandOptions) {if (this.commands.has(options.id)) {- console.warn(`Command ${options.id} already registered.`);+ commandLogger.warn(`Command ${options.id} already registered.`);return () => {};}const command = createAffineCommand(options);@@ -38,17 +41,17 @@ export const AffineCommandRegistry = new (class {});}- console.debug(`Registered command ${command.id}`);+ commandLogger.debug(`Registered command ${command.id}`);return () => {unsubKb?.();this.commands.delete(command.id);- console.debug(`Unregistered command ${command.id}`);+ commandLogger.debug(`Unregistered command ${command.id}`);};}get(id: string): AffineCommand | undefined {if (!this.commands.has(id)) {- console.warn(`Command ${id} not registered.`);+ commandLogger.warn(`Command ${id} not registered.`);return undefined;}return this.commands.get(id);diff --git a/packages/common/infra/tsconfig.json b/packages/common/infra/tsconfig.jsonindex 0941f63e4d..1e81c00cd2 100644--- a/packages/common/infra/tsconfig.json+++ b/packages/common/infra/tsconfig.json@@ -14,6 +14,9 @@{"path": "../env"},+ {+ "path": "../debug"+ },{"path": "./tsconfig.node.json"}diff --git a/yarn.lock b/yarn.lockindex 2bdcf4d680..d6958401ab 100644--- a/yarn.lock+++ b/yarn.lock@@ -13795,6 +13795,7 @@ __metadata:resolution: "@toeverything/infra@workspace:packages/common/infra"dependencies:"@affine-test/fixtures": "workspace:*"+ "@affine/debug": "workspace:*""@affine/env": "workspace:*""@affine/sdk": "workspace:*""@affine/templates": "workspace:*"