Module: Neovim::Logging Private

Included in:
Connection, EventLoop, Host, RemoteModule, Session
Defined in:
lib/neovim/logging.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Mixed into classes for unified logging helper methods.

Defined Under Namespace

Modules: Helpers

Constant Summary collapse

TIMESTAMP_FORMAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"%Y-%m-%dT%H:%M:%S.%6N".freeze

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/neovim/logging.rb', line 40

def self.included(base)
  base.send(:include, Helpers)
end

.logger(env = ENV) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the value of @logger, or construct it from the environment. $NVIM_RUBY_LOG_FILE specifies a file to log to (default STDERR), while $NVIM_RUBY_LOG_LEVEL specifies the level (default WARN)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/neovim/logging.rb', line 13

def self.logger(env=ENV)
  return @logger if instance_variable_defined?(:@logger)

  env_file, env_level =
    env.values_at("NVIM_RUBY_LOG_FILE", "NVIM_RUBY_LOG_LEVEL")

  @logger = Logger.new(env_file || STDERR)

  if /\S+/.match?(env_level)
    begin
      @logger.level = Integer(env_level)
    rescue ArgumentError
      @logger.level = Logger.const_get(env_level.upcase)
    end
  else
    @logger.level = Logger::WARN
  end

  @logger.formatter = json_formatter
  @logger
end

.logger=(logger) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
# File 'lib/neovim/logging.rb', line 35

def self.logger=(logger)
  logger.formatter = json_formatter
  @logger = logger
end