Module: OsCtl::Lib::Utils::Log::CommonMethods

Defined in:
lib/libosctl/utils/log.rb

Instance Method Summary collapse

Instance Method Details

#log(*args) ⇒ Object

Arguments are one of:

- `level`, `type`, `msg`
- `level`, `msg` (`type` is taken as `self`)
- `msg`

‘level` defaults to `info`, `type` to `general`.

If ‘type` responds to `log_type`, it is called to return the log type.

Log levels: PrivateMethods::LEVELS Types: init, general, regular, special types and any other



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/libosctl/utils/log.rb', line 37

def log(*args)
  case args.count
  when 3
    level, type, msg = args

    PrivateMethods.log(level, PrivateMethods.resolve_type(type), msg)

  when 2
    level, msg = args

    PrivateMethods.log(level, PrivateMethods.resolve_type(self), msg)

  when 1
    PrivateMethods.log(:info, :general, args.first)

  else
    raise 'Provide either one or three arguments'
  end
end