Skip to content

Commit

Permalink
chore: add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Nov 24, 2024
1 parent 6b0d772 commit 8decb41
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions packages/authz/src/space-member/space-member.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { inject, singleton } from "@undb/di"
import { and, None, Option } from "@undb/domain"
import { createLogger } from "@undb/logger"
import { injectSpaceService, type ISpaceId, type ISpaceService } from "@undb/space"
import type { SetContextValue } from "../../../context/src/context.type"
import { MemberIdVO } from "../member/member-id.vo"
Expand Down Expand Up @@ -32,6 +33,7 @@ export const injectSpaceMemberService = () => inject(SPACE_MEMBER_SERVICE)

@singleton()
export class SpaceMemberService implements ISpaceMemberService {
private logger = createLogger("SpaceMemberService")
constructor(
@injectSpaceService()
private readonly spaceService: ISpaceService,
Expand Down Expand Up @@ -110,6 +112,8 @@ export class SpaceMemberService implements ISpaceMemberService {
spaceId: ISpaceId,
userId: string,
): Promise<Option<SpaceMember>> {
this.logger.debug({ spaceId, userId }, "setSpaceMemberContext")

if (!spaceId || !userId) {
return None
}
Expand Down
1 change: 1 addition & 0 deletions packages/space/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"types": "src/index.d.ts",
"dependencies": {
"@undb/context": "workspace:*",
"@undb/logger": "workspace:*",
"ts-pattern": "^5.5.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/space/src/space.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { SetContextValue } from "@undb/context"
import { inject, singleton } from "@undb/di"
import { createLogger } from "@undb/logger"
import { None, Option, Some } from "oxide.ts"
import { match, P } from "ts-pattern"
import type { ICreateSpaceDTO, ISpaceDTO } from "./dto"
Expand Down Expand Up @@ -37,6 +38,7 @@ export const injectSpaceService = () => inject(SPACE_SERVICE)

@singleton()
export class SpaceService implements ISpaceService {
private logger = createLogger("SpaceService")
constructor(
@injectSpaceRepository()
private readonly spaceRepository: ISpaceRepository,
Expand Down Expand Up @@ -86,6 +88,7 @@ export class SpaceService implements ISpaceService {
}

async setSpaceContext(setContext: SetContextValue, input: IGetSpaceInput): Promise<Space> {
this.logger.debug(input, "setSpaceContext")
const space = await this.getSpace(input)
setContext("spaceId", space.unwrap().id.value)

Expand Down

0 comments on commit 8decb41

Please sign in to comment.