Skip to content

Commit

Permalink
feat(core): context-aware logger API
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 26, 2023
1 parent 9564c4c commit 97101b6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"shx": "^0.3.4",
"typescript": "^5.1.6",
"yakumo": "^0.3.13",
"yakumo-esbuild": "^0.3.25",
"yakumo-esbuild": "^0.3.26",
"yakumo-mocha": "^0.3.1",
"yakumo-publish": "^0.3.4",
"yakumo-publish-sync": "^0.3.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/axios/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cordis-axios",
"description": "Axios service for cordis",
"version": "4.0.0",
"version": "4.0.1",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"dependencies": {
"@satorijs/element": "^2.5.1",
"@satorijs/protocol": "^1.1.1",
"cordis": "^2.10.2",
"cordis-axios": "^4.0.0",
"cordis": "^3.0.2",
"cordis-axios": "^4.0.1",
"cosmokit": "^1.5.1",
"ws": "^8.14.2",
"reggol": "^1.5.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class Context extends cordis.Context {
}

logger(name: string) {
return new Logger(name)
return new Logger(name, { [Context.current]: this })
}

component(name: string, component: Component<this[typeof Context.session]>, options: Component.Options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Session<C extends Context = Context> {

async transform(elements: h[]): Promise<h[]> {
return await h.transformAsync(elements, ({ type, attrs, children }, session) => {
const render = type === 'component' ? attrs.is : this.app['component:' + type]
const render = type === 'component' ? attrs.is : this.app.get('component:' + type)
return render?.(attrs, children, session) ?? true
}, this)
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"target": "es2022",
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
Expand Down

0 comments on commit 97101b6

Please sign in to comment.