Class: Jekyll::Assets::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/assets/logger.rb

Constant Summary collapse

PREFIX =
"Assets: "
COLORS =
{
  error: :red,
  debug: :yellow,
  info:  :cyan,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.colorize?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/jekyll/assets/logger.rb', line 41

def self.colorize?
  @color ||= begin
    Jekyll.env == "development" && system("test -t 2")
  end
end

.err_file(file) ⇒ Object



36
37
38
# File 'lib/jekyll/assets/logger.rb', line 36

def self.err_file(file)
  Jekyll.logger.error("Asset File", file)
end

.loggerObject



18
19
20
# File 'lib/jekyll/assets/logger.rb', line 18

def self.logger
  self
end

.with_timed_logging(msg, type: :debug) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll/assets/logger.rb', line 23

def self.with_timed_logging(msg, type: :debug)
  s, t, out = Time.now, nil, yield; Logger.send(type) do
    format("\n#{msg}", {
      time: "#{t = Time.now - s}s",
    })
  end

  {
    result: out, time: t
  }
end

Instance Method Details

#vObject

Note:

this is to be removed after 3.6.

– Creates self methods so that we can accept blocks. –

Parameters:

  • message (String, Proc)

    the message that to log.

Returns:

  • nil



69
70
71
72
73
# File 'lib/jekyll/assets/logger.rb', line 69

%i(warn error info debug).each do |v|
  make_logger({
    type: v,
  })
end