From c8ff3394e692a56dc011df94067034195ffae4c7 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Mon, 9 Jun 2025 18:22:19 -0400 Subject: [PATCH] fix(core): remove log_error function and standardize logging (#31515) ## Current Behavior The codebase has separate `logError` and `logDebug` functions in the native logging infrastructure, with both error and debug logging paths. ## Expected Behavior Consolidate logging to use a single standardized approach. Error messages are now logged through the debug channel for consistency. ## Related Issue(s) This change standardizes the logging interface by removing the separate error logging function and routing all log messages through the debug logger. --- packages/nx/src/native/index.d.ts | 2 -- packages/nx/src/native/logger/console.rs | 6 ------ packages/nx/src/native/native-bindings.js | 1 - packages/nx/src/tasks-runner/run-command.ts | 4 ++-- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/nx/src/native/index.d.ts b/packages/nx/src/native/index.d.ts index 4517fef005..c7a25b48fc 100644 --- a/packages/nx/src/native/index.d.ts +++ b/packages/nx/src/native/index.d.ts @@ -249,8 +249,6 @@ export const IS_WASM: boolean export declare export declare function logDebug(message: string): void -export declare export declare function logError(message: string): void - /** Stripped version of the NxJson interface for use in rust */ export interface NxJson { namedInputs?: Record> diff --git a/packages/nx/src/native/logger/console.rs b/packages/nx/src/native/logger/console.rs index c9c8cef527..ad22b8218e 100644 --- a/packages/nx/src/native/logger/console.rs +++ b/packages/nx/src/native/logger/console.rs @@ -6,9 +6,3 @@ pub fn log_debug(message: String) { enable_logger(); debug!(message); } - -#[napi] -pub fn log_error(message: String) { - enable_logger(); - error!(message); -} diff --git a/packages/nx/src/native/native-bindings.js b/packages/nx/src/native/native-bindings.js index e7b0427c6b..63c62c84b3 100644 --- a/packages/nx/src/native/native-bindings.js +++ b/packages/nx/src/native/native-bindings.js @@ -392,7 +392,6 @@ module.exports.hashFile = nativeBinding.hashFile module.exports.installNxConsole = nativeBinding.installNxConsole module.exports.IS_WASM = nativeBinding.IS_WASM module.exports.logDebug = nativeBinding.logDebug -module.exports.logError = nativeBinding.logError module.exports.parseTaskStatus = nativeBinding.parseTaskStatus module.exports.remove = nativeBinding.remove module.exports.restoreTerminal = nativeBinding.restoreTerminal diff --git a/packages/nx/src/tasks-runner/run-command.ts b/packages/nx/src/tasks-runner/run-command.ts index 64279dc41a..43f8acf5b9 100644 --- a/packages/nx/src/tasks-runner/run-command.ts +++ b/packages/nx/src/tasks-runner/run-command.ts @@ -17,7 +17,7 @@ import { getTaskDetails, hashTasksThatDoNotDependOnOutputsOfOtherTasks, } from '../hasher/hash-task'; -import { logError, logDebug, RunMode } from '../native'; +import { logDebug, RunMode } from '../native'; import { runPostTasksExecution, runPreTasksExecution, @@ -216,7 +216,7 @@ async function getTerminalOutputLifeCycle( // @ts-ignore return (chunk, encoding, callback) => { if (isError) { - logError( + logDebug( Buffer.isBuffer(chunk) ? chunk.toString(encoding) : chunk.toString()