diff --git a/README.md b/README.md index 2ea95c30..c1adb9bd 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ For debugging and configuring logging, you can set the following environment var - `NVIM_NODE_HOST_DEBUG`: Spawns the node process that calls `neovim-client-host` with `--inspect-brk` so you can have a debugger. Pair that with this [Node Inspector Manager Chrome plugin](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en) - Logging: Logging is done using `winston` through the `logger` module. This package replaces `console` with this interface. - - `NVIM_NODE_LOG_LEVEL`: Sets the logging level for winston. Default is `debug`. + - `NVIM_NODE_LOG_LEVEL`: Sets the logging level for winston. Default is `error`. Available levels: `{ error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }` - `NVIM_NODE_LOG_FILE`: Sets the log file path. - Usage through node REPL diff --git a/packages/neovim/src/utils/logger.ts b/packages/neovim/src/utils/logger.ts index 726d0ff5..28d0fe12 100644 --- a/packages/neovim/src/utils/logger.ts +++ b/packages/neovim/src/utils/logger.ts @@ -1,7 +1,7 @@ import * as winston from 'winston'; import { inspect } from 'node:util'; -const level = process.env.NVIM_NODE_LOG_LEVEL || 'debug'; +const level = process.env.NVIM_NODE_LOG_LEVEL || 'error'; const loggerKeys = ['info', 'warn', 'error', 'debug', 'level'] as const; export type Logger = Pick; @@ -81,6 +81,11 @@ function setupWinstonLogger(): Logger { let _logger: Logger; // singleton export function getLogger() { if (!_logger) { + if (!process.env.NVIM_NODE_LOG_LEVEL) { + process.stderr.write( + "Note: Default log level changed from 'debug' to 'error'. Set NVIM_NODE_LOG_LEVEL=debug for verbose logging.\n" + ); + } _logger = setupWinstonLogger(); } return _logger;