Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion packages/neovim/src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -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<winston.Logger, (typeof loggerKeys)[number]>;
Expand Down Expand Up @@ -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;
Expand Down