Skip to content

Commit

Permalink
improv: pass whole configs to logger
Browse files Browse the repository at this point in the history
  • Loading branch information
winprn committed Oct 29, 2024
1 parent 6051efb commit de6a517
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/logger/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export class Logger {
// biome-ignore lint/suspicious/noExplicitAny: Do this to allow any method to be called on the logger
[key: string]: any;

constructor(context: string, level: loglevel.LogLevelDesc = "info") {
constructor(context: string, config?: LoggerOptions) {
this.log = loglevel.getLogger(context);
this.log.setLevel(level);
this.log.setLevel(config?.level || "info");
prefix.reg(loglevel);
prefix.apply(this.log, {
template: "%n",
Expand Down
2 changes: 1 addition & 1 deletion packages/network/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class TopologyNetworkNode {

constructor(config?: TopologyNetworkNodeConfig) {
this._config = config;
log = new Logger("topology::network", config?.log_config?.level);
log = new Logger("topology::network", config?.log_config);
}

async start() {
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 @@ -14,7 +14,10 @@ import type {
} from "../proto/rpc_pb.js";

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

function subscribeCro(
call: ServerUnaryCall<SubscribeCroRequest, SubscribeCroResponse>,
Expand Down
2 changes: 1 addition & 1 deletion packages/object/src/wasm/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Logger } from "@topology-foundation/logger";
import asc from "assemblyscript/asc";

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

log.info("Compiling", path);
const { error, stderr } = await asc.main(
Expand Down

0 comments on commit de6a517

Please sign in to comment.