Merge pull request #2307 from jekyll/obey-stevenson
This commit is contained in:
commit
0d85592085
|
@ -25,7 +25,7 @@ module Jekyll
|
||||||
options = configuration_from_options(options)
|
options = configuration_from_options(options)
|
||||||
site = Jekyll::Site.new(options)
|
site = Jekyll::Site.new(options)
|
||||||
|
|
||||||
Jekyll.logger.log_level = Jekyll::Stevenson::ERROR if options['quiet']
|
Jekyll.logger.log_level = :error if options['quiet']
|
||||||
|
|
||||||
build(site, options)
|
build(site, options)
|
||||||
watch(site, options) if options['watch']
|
watch(site, options) if options['watch']
|
||||||
|
|
|
@ -41,7 +41,7 @@ module Jekyll
|
||||||
if page.uses_relative_permalinks
|
if page.uses_relative_permalinks
|
||||||
Jekyll.logger.warn "Deprecation:", "'#{page.path}' uses relative" +
|
Jekyll.logger.warn "Deprecation:", "'#{page.path}' uses relative" +
|
||||||
" permalinks which will be deprecated in" +
|
" permalinks which will be deprecated in" +
|
||||||
" Jekyll v1.2 and beyond."
|
" Jekyll v2.0.0 and beyond."
|
||||||
contains_deprecated_pages = true
|
contains_deprecated_pages = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "New jekyll site installed in #{new_blog_path}."
|
Jekyll.logger.info "New jekyll site installed in #{new_blog_path}."
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_blank_site(path)
|
def self.create_blank_site(path)
|
||||||
|
|
|
@ -27,8 +27,7 @@ module Jekyll
|
||||||
'future' => true, # remove and make true just default
|
'future' => true, # remove and make true just default
|
||||||
'unpublished' => false,
|
'unpublished' => false,
|
||||||
|
|
||||||
'relative_permalinks' => true, # backwards-compatibility with < 1.0
|
'relative_permalinks' => false,
|
||||||
# will be set to false once 2.0 hits
|
|
||||||
|
|
||||||
'markdown' => 'kramdown',
|
'markdown' => 'kramdown',
|
||||||
'highlighter' => 'pygments',
|
'highlighter' => 'pygments',
|
||||||
|
|
|
@ -50,9 +50,9 @@ module Jekyll
|
||||||
self.data = SafeYAML.load($1)
|
self.data = SafeYAML.load($1)
|
||||||
end
|
end
|
||||||
rescue SyntaxError => e
|
rescue SyntaxError => e
|
||||||
puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
|
Jekyll.logger.warn "YAML Exception reading #{File.join(base, name)}: #{e.message}"
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "Error reading file #{File.join(base, name)}: #{e.message}"
|
Jekyll.logger.warn "Error reading file #{File.join(base, name)}: #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
self.data ||= {}
|
self.data ||= {}
|
||||||
|
|
|
@ -396,13 +396,11 @@ module Jekyll
|
||||||
|
|
||||||
def relative_permalinks_deprecation_method
|
def relative_permalinks_deprecation_method
|
||||||
if config['relative_permalinks'] && has_relative_page?
|
if config['relative_permalinks'] && has_relative_page?
|
||||||
$stderr.puts # Places newline after "Generating..."
|
|
||||||
Jekyll.logger.warn "Deprecation:", "Starting in 2.0, permalinks for pages" +
|
Jekyll.logger.warn "Deprecation:", "Starting in 2.0, permalinks for pages" +
|
||||||
" in subfolders must be relative to the" +
|
" in subfolders must be relative to the" +
|
||||||
" site source directory, not the parent" +
|
" site source directory, not the parent" +
|
||||||
" directory. Check http://jekyllrb.com/docs/upgrading/"+
|
" directory. Check http://jekyllrb.com/docs/upgrading/"+
|
||||||
" for more info."
|
" for more info."
|
||||||
$stderr.print Jekyll.logger.formatted_topic("") + "..." # for "done."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,19 @@ module Jekyll
|
||||||
class Stevenson
|
class Stevenson
|
||||||
attr_accessor :log_level
|
attr_accessor :log_level
|
||||||
|
|
||||||
DEBUG = 0
|
LOG_LEVELS = {
|
||||||
INFO = 1
|
debug: 0,
|
||||||
WARN = 2
|
info: 1,
|
||||||
ERROR = 3
|
warn: 2,
|
||||||
|
error: 3
|
||||||
|
}
|
||||||
|
|
||||||
# Public: Create a new instance of Stevenson, Jekyll's logger
|
# Public: Create a new instance of Stevenson, Jekyll's logger
|
||||||
#
|
#
|
||||||
# level - (optional, integer) the log level
|
# level - (optional, symbol) the log level
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def initialize(level = INFO)
|
def initialize(level = :info)
|
||||||
@log_level = level
|
@log_level = level
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def debug(topic, message = nil)
|
def debug(topic, message = nil)
|
||||||
$stdout.puts(message(topic, message)) if log_level <= DEBUG
|
$stdout.puts(message(topic, message)) if should_log(:debug)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Print a jekyll message to stdout
|
# Public: Print a jekyll message to stdout
|
||||||
|
@ -33,7 +35,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def info(topic, message = nil)
|
def info(topic, message = nil)
|
||||||
$stdout.puts(message(topic, message)) if log_level <= INFO
|
$stdout.puts(message(topic, message)) if should_log(:info)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Print a jekyll message to stderr
|
# Public: Print a jekyll message to stderr
|
||||||
|
@ -43,7 +45,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def warn(topic, message = nil)
|
def warn(topic, message = nil)
|
||||||
$stderr.puts(message(topic, message).yellow) if log_level <= WARN
|
$stderr.puts(message(topic, message).yellow) if should_log(:warn)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Print a jekyll error message to stderr
|
# Public: Print a jekyll error message to stderr
|
||||||
|
@ -53,7 +55,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def error(topic, message = nil)
|
def error(topic, message = nil)
|
||||||
$stderr.puts(message(topic, message).red) if log_level <= ERROR
|
$stderr.puts(message(topic, message).red) if should_log(:error)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Print a Jekyll error message to stderr and immediately abort the process
|
# Public: Print a Jekyll error message to stderr and immediately abort the process
|
||||||
|
@ -85,5 +87,16 @@ module Jekyll
|
||||||
def formatted_topic(topic)
|
def formatted_topic(topic)
|
||||||
"#{topic} ".rjust(20)
|
"#{topic} ".rjust(20)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Determine whether the current log level warrants logging at the
|
||||||
|
# proposed level.
|
||||||
|
#
|
||||||
|
# level_of_message - the log level of the message (symbol)
|
||||||
|
#
|
||||||
|
# Returns true if the log level of the message is greater than or equal to
|
||||||
|
# this logger's log level.
|
||||||
|
def should_log(level_of_message)
|
||||||
|
LOG_LEVELS.fetch(log_level) <= LOG_LEVELS.fetch(level_of_message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,4 +70,14 @@ class Test::Unit::TestCase
|
||||||
ensure
|
ensure
|
||||||
$stdout = $old_stdout
|
$stdout = $old_stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def capture_stderr
|
||||||
|
$old_stderr = $stderr
|
||||||
|
$stderr = StringIO.new
|
||||||
|
yield
|
||||||
|
$stderr.rewind
|
||||||
|
return $stderr.string
|
||||||
|
ensure
|
||||||
|
$stderr = $old_stderr
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
layout: default
|
layout: default
|
||||||
title : Page inside +
|
title : Page inside +
|
||||||
permalink: plus+in+url
|
permalink: /+/plus+in+url
|
||||||
---
|
---
|
||||||
Line 1
|
Line 1
|
||||||
{{ page.title }}
|
{{ page.title }}
|
||||||
|
|
|
@ -166,9 +166,9 @@ class TestConfiguration < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "successfully load a TOML file" do
|
should "successfully load a TOML file" do
|
||||||
Jekyll.logger.log_level = Jekyll::Stevenson::WARN
|
Jekyll.logger.log_level = :warn
|
||||||
assert_equal Jekyll::Configuration::DEFAULTS.merge({ "baseurl" => "/you-beautiful-blog-you", "title" => "My magnificent site, wut" }), Jekyll.configuration({ "config" => [@paths[:toml]] })
|
assert_equal Jekyll::Configuration::DEFAULTS.merge({ "baseurl" => "/you-beautiful-blog-you", "title" => "My magnificent site, wut" }), Jekyll.configuration({ "config" => [@paths[:toml]] })
|
||||||
Jekyll.logger.log_level = Jekyll::Stevenson::INFO
|
Jekyll.logger.log_level = :info
|
||||||
end
|
end
|
||||||
|
|
||||||
should "load multiple config files" do
|
should "load multiple config files" do
|
||||||
|
|
|
@ -21,7 +21,7 @@ class TestConvertible < Test::Unit::TestCase
|
||||||
|
|
||||||
should "not parse if there is syntax error in front-matter" do
|
should "not parse if there is syntax error in front-matter" do
|
||||||
name = 'broken_front_matter2.erb'
|
name = 'broken_front_matter2.erb'
|
||||||
out = capture_stdout do
|
out = capture_stderr do
|
||||||
ret = @convertible.read_yaml(@base, name)
|
ret = @convertible.read_yaml(@base, name)
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ class TestConvertible < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not allow ruby objects in yaml" do
|
should "not allow ruby objects in yaml" do
|
||||||
out = capture_stdout do
|
out = capture_stderr do
|
||||||
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
|
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
|
||||||
end
|
end
|
||||||
assert_no_match /undefined class\/module DoesNotExist/, out
|
assert_no_match /undefined class\/module DoesNotExist/, out
|
||||||
|
@ -38,7 +38,7 @@ class TestConvertible < Test::Unit::TestCase
|
||||||
|
|
||||||
should "not parse if there is encoding error in file" do
|
should "not parse if there is encoding error in file" do
|
||||||
name = 'broken_front_matter3.erb'
|
name = 'broken_front_matter3.erb'
|
||||||
out = capture_stdout do
|
out = capture_stderr do
|
||||||
ret = @convertible.read_yaml(@base, name, :encoding => 'utf-8')
|
ret = @convertible.read_yaml(@base, name, :encoding => 'utf-8')
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue