Add Jekyll::Logger
This commit is contained in:
parent
dcad4b2867
commit
61465053eb
|
@ -0,0 +1,42 @@
|
||||||
|
module Jekyll
|
||||||
|
module Logger
|
||||||
|
# Public: Print a jekyll message to stdout
|
||||||
|
#
|
||||||
|
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
|
||||||
|
# message - the message detail
|
||||||
|
#
|
||||||
|
# Returns nothing
|
||||||
|
def info(topic, message)
|
||||||
|
$stdout.puts Jekyll.message(topic, message)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Print a jekyll message to stderr
|
||||||
|
#
|
||||||
|
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
|
||||||
|
# message - the message detail
|
||||||
|
#
|
||||||
|
# Returns nothing
|
||||||
|
def warn(topic, message)
|
||||||
|
$stderr.puts Jekyll.message(topic, message)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Build a Jekyll topic method
|
||||||
|
#
|
||||||
|
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
|
||||||
|
# message - the message detail
|
||||||
|
#
|
||||||
|
# Returns the formatted message
|
||||||
|
def message(topic, message)
|
||||||
|
formatted_topic(topic) + message.gsub(/\s+/, ' ')
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Format the topic
|
||||||
|
#
|
||||||
|
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
|
||||||
|
#
|
||||||
|
# Returns the formatted topic statement
|
||||||
|
def formatted_topic(topic)
|
||||||
|
"#{topic} ".rjust(20)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue