Skip to content

Commit

Permalink
improv: use logger package for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
winprn committed Oct 29, 2024
1 parent 94174af commit c953ba8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@topology-foundation/blueprints": "0.2.0",
"@topology-foundation/network": "0.2.0",
"@topology-foundation/object": "0.2.0",
"@topology-foundation/logger": "0.2.0",
"commander": "^12.1.0",
"google-protobuf": "^3.21.2"
}
Expand Down
5 changes: 4 additions & 1 deletion packages/node/src/rpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import type {
UnsubscribeCroRequest,
UnsubscribeCroResponse,
} from "../proto/rpc_pb.js";
import { Logger } from "@topology-foundation/logger";

export function init(node: TopologyNode) {
const log = new Logger("topology::rpc", "info");

function subscribeCro(
call: ServerUnaryCall<SubscribeCroRequest, SubscribeCroResponse>,
callback: sendUnaryData<SubscribeCroResponse>,
Expand Down Expand Up @@ -80,7 +83,7 @@ export function init(node: TopologyNode) {
"0.0.0.0:6969",
grpc.ServerCredentials.createInsecure(),
(_error, _port) => {
console.log("running grpc in port:", _port);
log.info("running grpc in port:", _port);
},
);
}
3 changes: 3 additions & 0 deletions packages/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
{
"path": "../object"
},
{
"path": "../logger"
}
],
"include": ["src/**/*.ts", "src/**/*.js"]
Expand Down
1 change: 1 addition & 0 deletions packages/object/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"dependencies": {
"@bufbuild/protobuf": "^2.0.0",
"@topology-foundation/logger": "^0.2.0",
"ts-proto": "^2.2.4"
}
}
11 changes: 7 additions & 4 deletions packages/object/src/wasm/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
*/
import * as fs from "node:fs";
import asc from "assemblyscript/asc";
import { Logger } from "@topology-foundation/logger";

export async function compileWasm(path: string) {
console.log("Compiling", path);
const log = new Logger("topology::wasm", "info");

log.info("Compiling", path);
const { error, stderr } = await asc.main(
[path, "--bindings=esm", "--outFile=/tmp/dist.wasm"],
{
Expand All @@ -29,8 +32,8 @@ export async function compileWasm(path: string) {
);

if (error) {
console.log(`Compilation failed: ${error}`);
console.log(stderr.toString());
log.info(`Compilation failed: ${error}`);
log.info(stderr.toString());
return new Uint8Array();
}

Expand All @@ -39,6 +42,6 @@ export async function compileWasm(path: string) {
fs.readFileSync("/tmp/dist.wasm"),
);
// fs.unlinkSync('dist/tmp.wasm');
console.log("Compilation successful", bytecode);
log.info("Compilation successful", bytecode);
return bytecode;
}
5 changes: 5 additions & 0 deletions packages/object/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"compilerOptions": {
"outDir": "dist"
},
"references": [
{
"path": "../logger"
}
],
"include": ["src/**/*.ts"]
}

0 comments on commit c953ba8

Please sign in to comment.