Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cc6975b

Browse files
committedJul 30, 2024·
move decorator to utils package and remove extra logs
1 parent 83bcc42 commit cc6975b

File tree

9 files changed

+19
-42
lines changed

9 files changed

+19
-42
lines changed
 

‎pnpm-lock.yaml

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎v-next/core/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"@ignored/hardhat-vnext-node-test-reporter": "workspace:^3.0.0-next.2",
5858
"@microsoft/api-extractor": "^7.43.4",
5959
"@nomicfoundation/hardhat-test-utils": "workspace:^",
60-
"@types/debug": "^4.1.4",
6160
"@types/node": "^20.14.9",
6261
"@types/semver": "^7.5.8",
6362
"@typescript-eslint/eslint-plugin": "^7.7.1",
@@ -80,7 +79,6 @@
8079
"@ignored/hardhat-vnext-errors": "workspace:^3.0.0-next.2",
8180
"@ignored/hardhat-vnext-utils": "workspace:^3.0.0-next.2",
8281
"chalk": "^5.3.0",
83-
"debug": "^4.1.1",
8482
"env-paths": "^2.2.0",
8583
"semver": "^7.6.2"
8684
}

‎v-next/core/src/internal/hook-manager.ts

-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import {
1717
assertHardhatInvariant,
1818
} from "@ignored/hardhat-vnext-errors";
1919

20-
import { withDebugLogs } from "./debug.js";
21-
2220
export class HookManagerImplementation implements HookManager {
2321
readonly #pluginsInReverseOrder: HardhatPlugin[];
2422

@@ -101,7 +99,6 @@ export class HookManagerImplementation implements HookManager {
10199
);
102100
}
103101

104-
@withDebugLogs("HookManager:runHandlerChain")
105102
public async runHandlerChain<
106103
HookCategoryNameT extends keyof HardhatHooks,
107104
HookNameT extends keyof HardhatHooks[HookCategoryNameT],
@@ -140,7 +137,6 @@ export class HookManagerImplementation implements HookManager {
140137
return next(...handlerParams);
141138
}
142139

143-
@withDebugLogs("HookManager:runSequentialHandlers")
144140
public async runSequentialHandlers<
145141
HookCategoryNameT extends keyof HardhatHooks,
146142
HookNameT extends keyof HardhatHooks[HookCategoryNameT],
@@ -174,7 +170,6 @@ export class HookManagerImplementation implements HookManager {
174170
return result;
175171
}
176172

177-
@withDebugLogs("HookManager:runParallelHandlers")
178173
public async runParallelHandlers<
179174
HookCategoryNameT extends keyof HardhatHooks,
180175
HookNameT extends keyof HardhatHooks[HookCategoryNameT],

‎v-next/core/src/internal/hre.ts

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type { UserInterruptionManager } from "../types/user-interruptions.js";
1717
import { HardhatError } from "@ignored/hardhat-vnext-errors";
1818

1919
import { ResolvedConfigurationVariableImplementation } from "./configuration-variables.js";
20-
import { withDebugLogs } from "./debug.js";
2120
import {
2221
buildGlobalOptionDefinitions,
2322
resolveGlobalOptions,
@@ -30,7 +29,6 @@ import { UserInterruptionManagerImplementation } from "./user-interruptions.js";
3029
export class HardhatRuntimeEnvironmentImplementation
3130
implements HardhatRuntimeEnvironment
3231
{
33-
@withDebugLogs("HardhatRuntimeEnvironment:create")
3432
public static async create(
3533
inputUserConfig: HardhatUserConfig,
3634
userProvidedGlobalOptions: Partial<GlobalOptions>,

‎v-next/core/src/internal/tasks/resolved-task.ts

-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from "@ignored/hardhat-vnext-errors";
1919
import { ensureError } from "@ignored/hardhat-vnext-utils/error";
2020

21-
import { withDebugLogs } from "../debug.js";
2221
import { detectPluginNpmDependencyProblems } from "../plugins/detect-plugin-npm-dependency-problems.js";
2322

2423
import { formatTaskId } from "./utils.js";
@@ -27,7 +26,6 @@ import { validateTaskArgumentValue } from "./validations.js";
2726
export class ResolvedTask implements Task {
2827
readonly #hre: HardhatRuntimeEnvironment;
2928

30-
@withDebugLogs("ResolvedTask:createEmptyTask")
3129
public static createEmptyTask(
3230
hre: HardhatRuntimeEnvironment,
3331
id: string[],
@@ -46,7 +44,6 @@ export class ResolvedTask implements Task {
4644
);
4745
}
4846

49-
@withDebugLogs("ResolvedTask:createNewTask")
5047
public static createNewTask(
5148
hre: HardhatRuntimeEnvironment,
5249
id: string[],
@@ -95,7 +92,6 @@ export class ResolvedTask implements Task {
9592
* @throws HardhatError if the task is empty, a required argument is missing,
9693
* a argument has an invalid type, or the file actions can't be resolved.
9794
*/
98-
@withDebugLogs("ResolvedTask:run")
9995
public async run(taskArguments: TaskArguments): Promise<any> {
10096
if (this.isEmpty) {
10197
throw new HardhatError(HardhatError.ERRORS.TASK_DEFINITIONS.EMPTY_TASK, {

‎v-next/core/src/internal/tasks/task-manager.ts

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from "@ignored/hardhat-vnext-errors";
1616

1717
import { TaskDefinitionType } from "../../types/tasks.js";
18-
import { withDebugLogs } from "../debug.js";
1918

2019
import { ResolvedTask } from "./resolved-task.js";
2120
import { formatTaskId, getActorFragment } from "./utils.js";
@@ -63,7 +62,6 @@ export class TaskManagerImplementation implements TaskManager {
6362
return this.#rootTasks;
6463
}
6564

66-
@withDebugLogs("TaskManager:getTask")
6765
public getTask(taskId: string | string[]): Task {
6866
taskId = Array.isArray(taskId) ? taskId : [taskId];
6967
if (taskId.length === 0) {
@@ -101,7 +99,6 @@ export class TaskManagerImplementation implements TaskManager {
10199
return task;
102100
}
103101

104-
@withDebugLogs("TaskManager:insertTask")
105102
#insertTask(taskId: string[], task: Task, pluginId?: string) {
106103
if (taskId.length === 0) {
107104
throw new HardhatError(

‎v-next/hardhat-utils/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"./common-errors": "./dist/src/common-errors.js",
1919
"./crypto": "./dist/src/crypto.js",
2020
"./date": "./dist/src/date.js",
21+
"./debug": "./dist/src/debug.js",
2122
"./error": "./dist/src/error.js",
2223
"./eth": "./dist/src/eth.js",
2324
"./fs": "./dist/src/fs.js",
@@ -57,6 +58,7 @@
5758
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
5859
"@ignored/hardhat-vnext-node-test-reporter": "workspace:^3.0.0-next.2",
5960
"@types/bn.js": "^5.1.5",
61+
"@types/debug": "^4.1.4",
6062
"@types/keccak": "^3.0.4",
6163
"@types/node": "^20.14.9",
6264
"@typescript-eslint/eslint-plugin": "^7.7.1",
@@ -74,6 +76,7 @@
7476
"typescript-eslint": "7.7.1"
7577
},
7678
"dependencies": {
79+
"debug": "^4.1.1",
7780
"fast-equals": "^5.0.1",
7881
"keccak": "^3.0.4",
7982
"rfdc": "^1.3.1",

‎v-next/core/src/internal/debug.ts ‎v-next/hardhat-utils/src/debug.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import debugLib from "debug";
33
/**
44
* A simple decorator that adds debug logging for when a method is entered and exited.
55
*
6+
* This decorator is meant to be used for debugging purposes only. It should not be committed in runtime code.
7+
*
68
* Example usage:
79
*
810
* ```
@@ -22,7 +24,7 @@ export function withDebugLogs<This, Args extends any[], Return>(
2224
(this: This, ...args: Args) => Return
2325
>,
2426
): (this: This, ...args: Args) => Return {
25-
const log = debugLib(`hardhat:core${tag === "" ? "" : `:${tag}`}`);
27+
const log = debugLib(`hardhat:dev:core${tag === "" ? "" : `:${tag}`}`);
2628

2729
function replacementMethod(this: This, ...args: Args): Return {
2830
log(`Entering method with args:`, args);

‎v-next/hardhat/src/internal/cli/main.ts

+7-19
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,19 @@ export async function main(
5050

5151
let builtinGlobalOptions;
5252

53-
log("Hardhat CLI started with arguments:", cliArguments);
53+
log("Hardhat CLI started");
5454

5555
try {
5656
const usedCliArguments: boolean[] = new Array(cliArguments.length).fill(
5757
false,
5858
);
5959

60-
log("Parsing builtin global options");
61-
6260
builtinGlobalOptions = await parseBuiltinGlobalOptions(
6361
cliArguments,
6462
usedCliArguments,
6563
);
6664

67-
log("Parsed builtin global options:", builtinGlobalOptions);
65+
log("Parsed builtin global options");
6866

6967
if (builtinGlobalOptions.version) {
7068
return await printVersionMessage(print);
@@ -74,26 +72,20 @@ export async function main(
7472
return await initHardhat();
7573
}
7674

77-
log("Checking telemetry consent");
78-
7975
// TODO: the consent will be enabled in the other PRs related to telemetry
8076
const _telemetryConsent = await getTelemetryConsent();
8177

82-
log("Telemetry consent:", _telemetryConsent);
78+
log("Retrieved telemetry consent");
8379

8480
if (builtinGlobalOptions.configPath === undefined) {
85-
log("Config path not provided, attempting to resolve it");
86-
8781
builtinGlobalOptions.configPath = await resolveHardhatConfigPath();
8882

89-
log("Resolved config path:", builtinGlobalOptions.configPath);
83+
log("Resolved config path");
9084
}
9185

92-
log("Importing user config");
93-
9486
const userConfig = await importUserConfig(builtinGlobalOptions.configPath);
9587

96-
log("User config imported:", userConfig);
88+
log("User config imported");
9789

9890
const configPlugins = Array.isArray(userConfig.plugins)
9991
? userConfig.plugins
@@ -104,7 +96,7 @@ export async function main(
10496
builtinGlobalOptions.configPath,
10597
);
10698

107-
log("Resolved plugins:", resolvedPlugins);
99+
log("Resolved plugins");
108100

109101
const pluginGlobalOptionDefinitions =
110102
buildGlobalOptionDefinitions(resolvedPlugins);
@@ -118,8 +110,6 @@ export async function main(
118110
usedCliArguments,
119111
);
120112

121-
log("User provided global options:", userProvidedGlobalOptions);
122-
123113
log("Creating Hardhat Runtime Environment");
124114

125115
const hre = await createHardhatRuntimeEnvironment(
@@ -133,8 +123,6 @@ export async function main(
133123

134124
const taskOrId = parseTask(cliArguments, usedCliArguments, hre);
135125

136-
log("Parsed task:", taskOrId);
137-
138126
if (Array.isArray(taskOrId)) {
139127
if (taskOrId.length === 0) {
140128
const globalHelp = await getGlobalHelpString(
@@ -167,7 +155,7 @@ export async function main(
167155
task,
168156
);
169157

170-
log(`Running task "${task.id.join(" ")}" with arguments:`, taskArguments);
158+
log(`Running task "${task.id.join(" ")}"`);
171159

172160
await task.run(taskArguments);
173161
} catch (error) {

0 commit comments

Comments
 (0)
Please sign in to comment.