Class: ServiceInfo::Svlogd

Inherits:
Base
  • Object
show all
Defined in:
lib/runit-man/service_info/svlogd.rb

Overview

Represents information about service on svlogd-enabled host.

Constant Summary collapse

SPECIAL_LOG_FILES =
%w(lock config state newstate).freeze

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

[], #active?, all, #allowed_signals, #down!, #down?, #files_to_view, #files_to_watch, #initialize, itself_or_parent?, #log_pid, #logged?, #pid, real_data_from_file, #restart!, #run?, #send_signal, #started_at, #stat, #switch_down!, #switch_up!, #switchable?, #symlinks_to_file_paths, #to_hash, #to_json, #up!, #uptime, #urls_to_view, #watched_modified_files

Constructor Details

This class inherits a constructor from ServiceInfo::Base

Instance Method Details

#all_log_file_locationsObject

All log file locations



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/runit-man/service_info/svlogd.rb', line 22

def all_log_file_locations
  dir_name = log_folder
  return []  if dir_name.nil? || ! File.directory?(dir_name)
  r = []
  Dir.foreach(dir_name) do |name|
    next  if ServiceInfo::Base.itself_or_parent?(name)
    next  if SPECIAL_LOG_FILES.include?(name)

    path = File.expand_path(name, dir_name)
    next  unless File.readable?(path)

    stats = File.stat(path)
    stat_times = [stats.ctime.utc, stats.mtime.utc]
    min_time, max_time = stat_times.min, stat_times.max

    if min_time != max_time
      stat_times = "#{I18n.l(min_time)}-#{I18n.l(max_time)}"
    else
      stat_times = I18n.l(min_time)
    end

    label = "#{Utils.host_name}-#{self.name}-#{stat_times}.log"
    label = label.gsub(/[\:\s\,]/, '-').gsub(/[\\\/]/, '.')
    r << {
      :name     => name,
      :path     => path,
      :subdir   => "_",
      :label    => label,
      :size     => stats.size,
      :created  => min_time,
      :modified => max_time
    }
  end
  sorted_file_locations(r)
end

#log_file_locationsObject

Current log file locations



14
15
16
17
18
19
# File 'lib/runit-man/service_info/svlogd.rb', line 14

def log_file_locations
  folder = log_folder
  return []  if folder.nil?

  [ File.join(folder, 'current') ]
end

#log_folderObject



9
10
11
# File 'lib/runit-man/service_info/svlogd.rb', line 9

def log_folder
  log_folder_base_name
end

#logger_nameObject



5
6
7
# File 'lib/runit-man/service_info/svlogd.rb', line 5

def logger_name
  'svlogd'
end