Class Webgen::Logger
In: lib/webgen/logger.rb
Parent: Object
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Helpers Configuration Node Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Tree FileSystem Sitemap Copy Feed Virtual Sitemap Directory Page Fragment Template Metainfo Memory Coderay Sitemap IncludeFile BreadcrumbTrail Langbar TikZ Menu Tags Fragments Resource Website Tidy Head Kramdown Less Xmllint Blocks Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand WebguiCommand CreateCommand ApplyCommand WebsiteAccess Main Loggable OutputPathHelpers ExecuteCommand Link Date Relocatable Metainfo ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils Scss RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash TarArchive Stacked FileSystem lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/context/render.rb lib/webgen/website.rb lib/webgen/blackboard.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/configuration.rb lib/webgen/path.rb lib/webgen/webgentask.rb lib/webgen/page.rb lib/webgen/node.rb ClassMethods WebsiteAccess lib/webgen/cli/run_command.rb lib/webgen/cli/utils.rb lib/webgen/cli/apply_command.rb lib/webgen/cli/webgui_command.rb lib/webgen/cli.rb lib/webgen/cli/create_command.rb Color CLI LanguageManager lib/webgen/output/filesystem.rb Output lib/webgen/common/sitemap.rb Common lib/webgen/sourcehandler/memory.rb lib/webgen/sourcehandler/metainfo.rb lib/webgen/sourcehandler/copy.rb lib/webgen/sourcehandler/directory.rb lib/webgen/sourcehandler.rb lib/webgen/sourcehandler/page.rb lib/webgen/sourcehandler/template.rb lib/webgen/sourcehandler/fragment.rb lib/webgen/sourcehandler/sitemap.rb lib/webgen/sourcehandler/virtual.rb lib/webgen/sourcehandler/feed.rb OutputPathHelpers Base SourceHandler lib/webgen/tag/coderay.rb lib/webgen/tag/relocatable.rb lib/webgen/tag/menu.rb lib/webgen/tag/langbar.rb lib/webgen/tag/executecommand.rb lib/webgen/tag/breadcrumbtrail.rb lib/webgen/tag/metainfo.rb lib/webgen/tag/includefile.rb lib/webgen/tag/link.rb lib/webgen/tag/date.rb lib/webgen/tag/tikz.rb lib/webgen/tag/sitemap.rb Base Tag lib/webgen/contentprocessor/less.rb lib/webgen/contentprocessor/scss.rb lib/webgen/contentprocessor/blocks.rb lib/webgen/contentprocessor/rdoc.rb lib/webgen/contentprocessor/sass.rb lib/webgen/contentprocessor/erb.rb lib/webgen/contentprocessor/rdiscount.rb lib/webgen/contentprocessor/tags.rb lib/webgen/contentprocessor/erubis.rb lib/webgen/contentprocessor/kramdown/html.rb lib/webgen/contentprocessor/haml.rb lib/webgen/contentprocessor/maruku.rb lib/webgen/contentprocessor/xmllint.rb lib/webgen/contentprocessor/kramdown.rb lib/webgen/contentprocessor/head.rb lib/webgen/contentprocessor/builder.rb lib/webgen/contentprocessor/tidy.rb lib/webgen/contentprocessor/redcloth.rb lib/webgen/contentprocessor/fragments.rb lib/webgen/contentprocessor.rb ContentProcessor lib/webgen/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source Loggable Webgen dot/m_82_0.png

The class used by a Website to do the logging and the normal output.

Methods

debug   error   info   level   level=   log   log_output   mark_new_cycle   new   stdout   verbose   warn  

Attributes

sync  [R]  Specifies whether log output should be synchronous with normal output.
verbosity  [RW]  Normal output verbosity (:normal, :verbose, :quiet).

Public Class methods

Create a new Logger object which uses outdev as output device. If sync is set to true, log messages are interspersed with normal output.

[Source]

    # File lib/webgen/logger.rb, line 19
19:     def initialize(outdev=$stdout, sync=false)
20:       @sync = sync
21:       @outdev = outdev
22:       @logger = (@sync ? ::Logger.new(@outdev) : ::Logger.new(@logio = StringIO.new))
23:       @logger.formatter = Proc.new do |severity, timestamp, progname, msg|
24:         if self.level == ::Logger::DEBUG
25:           "%5s -- %s: %s\n" % [severity, progname, msg ]
26:         else
27:           "%5s -- %s\n" % [severity, msg]
28:         end
29:       end
30:       self.level = ::Logger::WARN
31:       self.verbosity = :normal
32:       @marks = []
33:     end

Public Instance methods

Utiltity method for logging a debug message.

[Source]

    # File lib/webgen/logger.rb, line 87
87:     def debug(source='', &block); log(:debug, source, &block); end

Utiltity method for logging an error message.

[Source]

    # File lib/webgen/logger.rb, line 78
78:     def error(source='', &block); log(:error, source, &block); end

Utiltity method for logging an informational message.

[Source]

    # File lib/webgen/logger.rb, line 84
84:     def info(source='', &block); log(:info, source, &block); end

The severity threshold level.

[Source]

    # File lib/webgen/logger.rb, line 57
57:     def level
58:       @logger.level
59:     end

Set the severity threshold to value which can be one of the stdlib Logger severity levels.

[Source]

    # File lib/webgen/logger.rb, line 62
62:     def level=(value)
63:       @logger.level = value
64:     end

Log a message of sev_level from source. The mandatory block has to return the message.

[Source]

    # File lib/webgen/logger.rb, line 67
67:     def log(sev_level, source='', &block)
68:       if sev_level == :stdout
69:         @outdev.write(block.call + "\n") if @verbosity == :normal || @verbosity == :verbose
70:       elsif sev_level == :verbose
71:         @outdev.write(block.call + "\n") if @verbosity == :verbose
72:       else
73:         @logger.send(sev_level, source, &block)
74:       end
75:     end

Returns the output of the logger when sync is false. Otherwise an empty string is returned.

[Source]

    # File lib/webgen/logger.rb, line 36
36:     def log_output
37:       if @sync
38:         ''
39:       else
40:         out = @logio.string.dup
41:         @marks.reverse.each_with_index do |mark, index|
42:           out.insert(mark, " INFO -- Log messages for run #{@marks.length - index} are following\n")
43:         end if out.length > 0
44:         out
45:       end
46:     end

Only used when sync is +false: Mark the location in the log stream where a new update/write run begins.

[Source]

    # File lib/webgen/logger.rb, line 50
50:     def mark_new_cycle
51:       if !@sync
52:         @marks << @logio.string.length
53:       end
54:     end

Utiltity method for writing a normal output message.

[Source]

    # File lib/webgen/logger.rb, line 90
90:     def stdout(source='', &block); log(:stdout, source, &block); end

Utiltity method for writing a verbose output message.

[Source]

    # File lib/webgen/logger.rb, line 93
93:     def verbose(source='', &block); log(:verbose, source, &block); end

Utiltity method for logging a warning message.

[Source]

    # File lib/webgen/logger.rb, line 81
81:     def warn(source='', &block); log(:warn, source, &block); end

[Validate]