class Locd::Newsyslog::Entry
Lil' class that holds values for a `newsyslog` conf file entry.
@see developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/newsyslog.conf.5.html @see archive.is/nIiP9
Constants
- FIELD_SEP
- NO_FLAGS
Conf file value for `flags` where there are none
@return [String]
- WHEN_NEVER
Value for the `when` field when we want to never rotate based on time.
@return [String]
Attributes
Public Class Methods
mode_string_for(mode)
click to toggle source
@todo Document normalize_mode method.
@param [type] arg_name
@todo Add name param description.
@return [String]
# File lib/locd/newsyslog.rb, line 72 def self.mode_string_for mode # t.match mode, # 0000..0777, mode.to_s( 8 ), # /\A[0-7]{3}\z/, mode case mode when 0000..0777 mode.to_s 8 when /\A[0-7]{3}\z/ mode else raise ArgumentError, "Bad mode: #{ mode.inspect }, need String or Fixnum: '644'; 0644" end end
new(log_path:, pid_path:, owner: nil, group: nil, mode: '644', count: 7, size: 100, when_: '*', flags: [], signal: 'HUP')
click to toggle source
Instantiate a new `Entry`.
# File lib/locd/newsyslog.rb, line 120 def initialize log_path:, pid_path:, owner: nil, group: nil, mode: '644', count: 7, size: 100, # 100 KB max size when_: '*', # '$D0', # rotate every day at midnight flags: [], signal: 'HUP' @log_path = log_path @pid_path = pid_path @owner = owner @group = group @mode = self.class.mode_string_for mode @count = t.pos_int.check count @size = t.pos_int.check size @when_ = when_ @flags = flags @sig_num = self.class.sig_num_for signal render end
sig_num_for(signal)
click to toggle source
# File lib/locd/newsyslog.rb, line 89 def self.sig_num_for signal case signal when String Signal.list.fetch signal when Fixnum signal else raise ArgumentError, "Bad signal: #{ signal.inspect }, need String or Fixnum: 'HUP'; 1" end end
Public Instance Methods
render()
click to toggle source
# File lib/locd/newsyslog.rb, line 162 def render @render ||= begin fields = [ log_path, "#{ owner }:#{ group }", mode, count, size, when_, render_flags, ] if pid_path fields << pid_path fields << sig_num end fields.map( &:to_s ).join FIELD_SEP end end
render_flags()
click to toggle source
# File lib/locd/newsyslog.rb, line 153 def render_flags if flags.empty? NO_FLAGS else flags.join end end