Module: PuppetEditorServices

Defined in:
lib/puppet_editor_services/server/tcp.rb,
lib/puppet_editor_services/server.rb,
lib/puppet_editor_services/logging.rb,
lib/puppet_editor_services/version.rb,
lib/puppet_editor_services/server/base.rb,
lib/puppet_editor_services/handler/base.rb,
lib/puppet_editor_services/server/stdio.rb,
lib/puppet_editor_services/protocol/base.rb,
lib/puppet_editor_services/connection/tcp.rb,
lib/puppet_editor_services/connection/base.rb,
lib/puppet_editor_services/connection/stdio.rb,
lib/puppet_editor_services/handler/json_rpc.rb,
lib/puppet_editor_services/protocol/json_rpc.rb,
lib/puppet_editor_services/handler/debug_adapter.rb,
lib/puppet_editor_services/protocol/debug_adapter.rb,
lib/puppet_editor_services/protocol/json_rpc_messages.rb,
lib/puppet_editor_services/protocol/debug_adapter_messages.rb

Overview

Defined Under Namespace

Modules: Connection, Handler, Protocol, Server

Constant Summary collapse

PUPPETEDITORSERVICESVERSION =
'2.0.4'

Class Method Summary collapse

Class Method Details

.init_logging(options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/puppet_editor_services/logging.rb', line 24

def self.init_logging(options)
  @log_file = nil
  if options[:debug].nil?
    @logger = nil
  elsif (options[:debug].casecmp 'stdout').zero?
    @logger = Logger.new($stdout)
  elsif !options[:debug].to_s.empty?
    # Log to file
    begin
      @log_file = File.open(options[:debug], 'w')
    rescue Errno::ENOENT => e
      # We can't open the log file and we can't log to STDOUT if we're in STDIO mode
      # So log the error to STDERR and disable logging
      $stderr.puts "Error opening log file #{options[:debug]} : #{e}" # rubocop:disable Style/StderrPuts
      @log_file = nil
      return
    end
    @log_file.sync = true
    @logger = Logger.new(@log_file)
  end
end

.log_message(severity, message) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet_editor_services/logging.rb', line 4

def self.log_message(severity, message)
  return if @logger.nil?

  case severity
  when :debug
    @logger.debug(message)
  when :info
    @logger.info(message)
  when :warn
    @logger.warn(message)
  when :error
    @logger.error(message)
  when :fatal
    @logger.fatal(message)
  else
    @logger.unknown(message)
  end
  @log_file.fsync unless @log_file.nil?
end

.versionString

Returns containing the editor services version, e.g. “0.4.0”.

Returns:

  • (String)

    containing the editor services version, e.g. “0.4.0”



9
10
11
12
13
14
15
16
# File 'lib/puppet_editor_services/version.rb', line 9

def self.version
  return @editor_services_version if @editor_services_version

  version_file = File.join(File.dirname(__FILE__), 'VERSION')
  version = read_version_file(version_file)

  @editor_services_version = version.nil? ? PUPPETEDITORSERVICESVERSION : version
end

.version=(version) ⇒ void

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.

This method returns an undefined value.

Sets the editor services version Typically only used in testing



24
25
26
# File 'lib/puppet_editor_services/version.rb', line 24

def self.version=(version)
  @editor_services_version = version
end