diff --git a/packages/network/package.json b/packages/network/package.json index a2f0bfca..ee9e7b2f 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -47,7 +47,6 @@ "@libp2p/webtransport": "^4.1.2", "@multiformats/multiaddr": "^12.3.0", "it-pipe": "^3.0.1", - "libp2p": "^1.8.3", - "tslog": "^4.9.3" + "libp2p": "^1.8.3" } } diff --git a/packages/network/src/node.ts b/packages/network/src/node.ts index cd232173..ac2413c9 100644 --- a/packages/network/src/node.ts +++ b/packages/network/src/node.ts @@ -24,9 +24,6 @@ import { bootstrap } from "@libp2p/bootstrap"; import { webTransport } from "@libp2p/webtransport"; import { autoNAT } from "@libp2p/autonat"; import { fromString as uint8ArrayFromString } from "uint8arrays/from-string"; -import { Logger, ILogObj, ISettingsParam } from "tslog"; - -let log: Logger = new Logger(); // snake_casing to match the JSON config export interface TopologyNetworkNodeConfig { @@ -34,7 +31,6 @@ export interface TopologyNetworkNodeConfig { bootstrap?: boolean; bootstrap_peers?: string[]; private_key_seed?: string; - tslog_config?: ISettingsParam; } export class TopologyNetworkNode { @@ -46,8 +42,6 @@ export class TopologyNetworkNode { constructor(config?: TopologyNetworkNodeConfig) { this._config = config; - log = new Logger(config?.tslog_config); - log.settings.name = "topology::network"; } async start() { @@ -121,47 +115,60 @@ export class TopologyNetworkNode { this._pubsub = this._node.services.pubsub as PubSub; this.peerId = this._node.peerId.toString(); - log.info("::start", "Successfuly started topology network w/ peer_id", this.peerId); + console.log( + "topology::network::start: Successfuly started topology network w/ peer_id", + this.peerId, + ); // TODO remove this or add better logger // we need to keep it now for debugging this._node.addEventListener("peer:connect", (e) => - log.info("::start::peer::connect", e.detail) + console.log("peer:connect", e.detail), ); this._node.addEventListener("peer:discovery", (e) => - log.info("::start::peer::discovery", e.detail) + console.log("peer:discovery", e.detail), ); this._node.addEventListener("peer:identify", (e) => - log.info("::start::peer::identify", e.detail) + console.log("peer:identify", e.detail), ); } subscribe(topic: string) { if (!this._node) { - log.error("::subscribe", "Node not initialized, please run .start()"); + console.error( + "topology::network::subscribe: Node not initialized, please run .start()", + ); return; } try { this._pubsub?.subscribe(topic); this._pubsub?.getPeers(); - log.info("::subscribe", "Successfuly subscribed the topic", topic); + console.log( + "topology::network::subscribe: Successfuly subscribed the topic", + topic, + ); } catch (e) { - log.error("::subscribe", e); + console.error("topology::network::subscribe:", e); } } unsubscribe(topic: string) { if (!this._node) { - log.error("::unsubscribe", "Node not initialized, please run .start()"); + console.error( + "topology::network::unsubscribe: Node not initialized, please run .start()", + ); return; } try { this._pubsub?.unsubscribe(topic); - log.info("::unsubscribe", "Successfuly unsubscribed the topic", topic); + console.log( + "topology::network::unsubscribe: Successfuly unsubscribed the topic", + topic, + ); } catch (e) { - log.error("::unsubscribe", e); + console.error("topology::network::unsubscribe:", e); } } @@ -182,9 +189,12 @@ export class TopologyNetworkNode { if (this._pubsub?.getSubscribers(topic)?.length === 0) return; await this._pubsub?.publish(topic, message); - log.info("::broadcastMessage", "Successfuly broadcasted message to topic", topic); + console.log( + "topology::network::broadcastMessage: Successfuly broadcasted message to topic", + topic, + ); } catch (e) { - log.error("::sendMessage", e); + console.error("topology::network::broadcastMessage:", e); } } @@ -194,9 +204,11 @@ export class TopologyNetworkNode { const stream = await connection?.newStream(protocols); stringToStream(stream, message); - log.info("::sendMessage", "Successfuly sent message to peer", peerId); + console.log( + `topology::network::sendMessage: Successfuly sent message to peer: ${peerId} with message: ${message}`, + ); } catch (e) { - log.error("::sendMessage", e); + console.error("topology::network::sendMessage:", e); } } @@ -214,9 +226,11 @@ export class TopologyNetworkNode { const stream: Stream = (await connection?.newStream(protocols)) as Stream; stringToStream(stream, message); - log.info("::sendGroupMessageRandomPeer", `Successfuly sent message to peer: ${peerId} with message: ${message}`); + console.log( + `topology::network::sendMessageRandomTopicPeer: Successfuly sent message to peer: ${peerId} with message: ${message}`, + ); } catch (e) { - log.error("::sendGroupMessageRandomPeer", e); + console.error("topology::network::sendMessageRandomTopicPeer:", e); } } diff --git a/packages/node/configs/bootstrap.json b/packages/node/configs/bootstrap.json index 4030b8f1..549106bb 100644 --- a/packages/node/configs/bootstrap.json +++ b/packages/node/configs/bootstrap.json @@ -6,10 +6,5 @@ "/dns4/relay.droak.sh/tcp/443/wss/p2p/Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP" ], "private_key_seed": "bootstrap" - }, - "tslog_config": { - "minLevel": 3, - "type": "hidden", - "hideLogPositionForProduction": true } } diff --git a/packages/node/configs/example.json b/packages/node/configs/example.json deleted file mode 100644 index 9034e71a..00000000 --- a/packages/node/configs/example.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "network_config": { - "addresses": ["/webrtc"], - "bootstrap_peers": [ - "/ip4/127.0.0.1/tcp/50000/ws/p2p/12D3KooWC6sm9iwmYbeQJCJipKTRghmABNz1wnpJANvSMabvecwJ" - ], - "private_key_seed": "node" - }, - "tslog_config": { - // Visit https://tslog.js.org/#/ for full reference - - // "pretty" for formatted output, "json" for JSON output, "hidden" to suppress output - "type": "pretty", - - // Optional name for the logger - "name": "mainLogger", - - // Minimum log level (0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal) - "minLevel": 3, - - // Name of the property to store log arguments (if needed) - "argumentsArrayName": "argumentsArray", - - // Set to true to improve performance in production by hiding log positions - "hideLogPositionForProduction": false, - - // Template for pretty log output - "prettyLogTemplate": "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t[{{filePathWithLine}}{{name}}]\t", - - // Template for pretty error output - "prettyErrorTemplate": "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}", - - // Template for pretty error stack trace lines - "prettyErrorStackTemplate": " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}", - - // Separator for parent logger names - "prettyErrorParentNamesSeparator": ":", - - // Delimiter for logger name in error output - "prettyErrorLoggerNameDelimiter": "\t", - - // Enable or disable styling of pretty logs - "stylePrettyLogs": true, - - // Timezone for pretty log messages ("UTC" or "local") - "prettyLogTimeZone": "UTC", - - // Styles for different parts of the pretty log output - "prettyLogStyles": { - // ... (styles configuration, example below) - "logLevelName": { - "*": ["bold", "black", "bgWhiteBright", "dim"], - "SILLY": ["bold", "white"], - "TRACE": ["bold", "whiteBright"], - "DEBUG": ["bold", "green"], - "INFO": ["bold", "blue"], - "WARN": ["bold", "yellow"], - "ERROR": ["bold", "red"], - "FATAL": ["bold", "redBright"] - }, - "dateIsoStr": "white", - "filePathWithLine": "white", - "name": ["white", "bold"], - "nameWithDelimiterPrefix": ["white", "bold"], - "nameWithDelimiterSuffix": ["white", "bold"], - "errorName": ["bold", "bgRedBright", "whiteBright"], - "fileName": ["yellow"], - "fileNameWithLine": "white" - }, - - // Options for util.inspect when formatting objects - "prettyInspectOptions": { - "colors": true, - "depth": 4 - }, - - // Placeholder for masked values - "maskPlaceholder": "[***]", - - // Array of keys whose values should be masked - "maskValuesOfKeys": ["password"], - - // Whether to match mask keys case-insensitively - "maskValuesOfKeysCaseInsensitive": false, - - // RegEx for masking values (null to disable) - "maskValuesRegEx": null, - - // Array of prefixes to add to log messages - "prefix": [], - - // Array of attached transport functions - "attachedTransports": [], - - // Property name for storing meta information - "metaProperty": "_meta", - - // Overwrite default behavior (all null by default) - "overwrite": { - "mask": null, - "toLogObj": null, - "addMeta": null, - "formatMeta": null, - "formatLogObj": null, - "transportFormatted": null, - "transportJSON": null, - "addPlaceholders": null - } - } - - } - \ No newline at end of file diff --git a/packages/node/configs/node.json b/packages/node/configs/node.json index fe56312b..d660844a 100644 --- a/packages/node/configs/node.json +++ b/packages/node/configs/node.json @@ -5,10 +5,5 @@ "/ip4/127.0.0.1/tcp/50000/ws/p2p/12D3KooWC6sm9iwmYbeQJCJipKTRghmABNz1wnpJANvSMabvecwJ" ], "private_key_seed": "node" - }, - "tslog_config": { - "minLevel": 3, - "type": "hidden", - "hideLogPositionForProduction": true } } diff --git a/packages/node/package.json b/packages/node/package.json index 4cbe69db..f9951cbd 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -38,7 +38,6 @@ "@topology-foundation/crdt": "0.0.23-5", "@topology-foundation/network": "0.0.23-5", "@topology-foundation/object": "0.0.23-5", - "commander": "^12.1.0", - "tslog": "^4.9.3" + "commander": "^12.1.0" } } diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 0b24dac7..f304f5f5 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -10,14 +10,12 @@ import { TopologyObjectStore, TopologyObjectStoreCallback } from "./store"; import { fromString as uint8ArrayFromString } from "uint8arrays/from-string"; import { toString as uint8ArrayToString } from "uint8arrays/to-string"; import { OPERATIONS } from "./operations.js"; -import { ILogObj, ISettingsParam } from "tslog" export * from "./operations.js"; // snake_casing to match the JSON config export interface TopologyNodeConfig { network_config?: TopologyNetworkNodeConfig; - tslog_config?: ISettingsParam; } export class TopologyNode { @@ -28,19 +26,7 @@ export class TopologyNode { constructor(config?: TopologyNodeConfig) { this._config = config; - if(!this._config) this._config = {}; - if(!this._config?.tslog_config){ - this._config.tslog_config = { - type: "hidden", - minLevel: 3, - hideLogPositionForProduction: true, - prettyLogTemplate: "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t{{filePathWithLine}}{{name}}" - }; - } - if(!this._config.network_config?.tslog_config){ - this._config.network_config = { tslog_config: this._config?.tslog_config }; - } - this.networkNode = new TopologyNetworkNode(this._config?.network_config); + this.networkNode = new TopologyNetworkNode(config?.network_config); this._objectStore = new TopologyObjectStore(); } diff --git a/packages/node/src/version.ts b/packages/node/src/version.ts index 2d05f320..85ceb686 100644 --- a/packages/node/src/version.ts +++ b/packages/node/src/version.ts @@ -1 +1 @@ -export const VERSION = "0.0.23-5"; +export const VERSION = "0.0.22"; diff --git a/tsconfig.json b/tsconfig.json index 1b70efcb..0d668bc6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,6 @@ "skipLibCheck": true, "stripInternal": true, - "resolveJsonModule": true, - "inlineSourceMap": true + "resolveJsonModule": true } }