Skip to content

Commit

Permalink
fix: cleaner tslog config file, default no logs
Browse files Browse the repository at this point in the history
  • Loading branch information
JanLewDev committed Aug 8, 2024
1 parent a5f76ba commit db0820d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
15 changes: 3 additions & 12 deletions packages/network/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,10 @@ import { autoNAT } from "@libp2p/autonat";
import { fromString as uint8ArrayFromString } from "uint8arrays/from-string";

import { Logger } from "tslog";
// import * as fs from 'fs';
// import * as path from 'path';
import tslogconfig from "../tslog.config";
tslogconfig.name = "topology:network";
const mainLogger = new Logger(tslogconfig);

// const readJson = (filePath: string) => {
// return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
// };

// const nodePackagePath = path.resolve(__dirname, '../node/package.json');
// const nodePackageOptions = readJson(nodePackagePath);
// const { loggerOptions } = nodePackageOptions;

// const mainLogger = new Logger({ name: "topology:network", ...loggerOptions}); // 3 = INFO
const mainLogger = new Logger({ name: "topology:network", type: "pretty", minLevel: 3 }); // 3 = INFO
const startLogger = mainLogger.getSubLogger({ name: "start" });
const subscribeLogger = mainLogger.getSubLogger({ name: "subscribe" });
const unsubscribeLogger = mainLogger.getSubLogger({ name: "unsubscribe" });
Expand Down
5 changes: 2 additions & 3 deletions packages/network/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"inlineSourceMap": true
"outDir": "dist"
},
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts", "./*ts"]
}
10 changes: 10 additions & 0 deletions packages/network/tslog.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ILogObj, ISettingsParam } from "tslog"

// https://tslog.js.org/#/?id=settings
const tslogconfig: ISettingsParam<ILogObj> = {
minLevel: 3, // 3 = INFO
type: "hidden", // "pretty" | "json" | "hidden"
hideLogPositionForProduction: true,
};

export default tslogconfig;
4 changes: 0 additions & 4 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,5 @@
"@topology-foundation/object": "0.0.23-5",
"commander": "^12.1.0",
"tslog": "^4.9.3"
},
"loggerOptions": {
"minLevel": "info",
"type": "pretty"
}
}
3 changes: 1 addition & 2 deletions packages/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"inlineSourceMap": true
"outDir": "dist"
},
"references": [
{
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"skipLibCheck": true,
"stripInternal": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"inlineSourceMap": true
}
}

0 comments on commit db0820d

Please sign in to comment.