Sha256: fa81331c8a7ad57a10c3ce2852b98a86575c6e600813f316be4670824522093e

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

# frozen_string_literal: true

require 'singleton'
require_relative 'application'

# Display and log project messages
class Logger
  include Singleton

  def initialize
    @logfile = null
  end

  ##
  # Display and log text
  def self.verbose(msg)
    print msg if Application.instance.config['global']['verbose'] == 'yes'
    @logfile&.write(msg)
  end

  ##
  # Display and log text line
  def self.verboseln(msg)
    verbose(msg + "\n")
  end

  ##
  # Create or reset logfile
  def self.create(project)
    @logfile = File.open(project.get(:logpath), 'w')
    @logfile.write('=' * 50 + "\n")
    @logfile.write("Created by : #{Application::NAME}")
    @logfile.write(" (version #{Application::VERSION})\n")
    @logfile.write("File       : #{project.get(:logname)}\n")
    @logfile.write("Time       : #{Time.new}\n")
    @logfile.write("Author     : David Vargas Ruiz\n")
    @logfile.write('=' * 50 + "\n\n")
  end

  ##
  # Close Log file
  def self.close
    @logfile.close
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asker-tool-2.2.0 lib/asker/logger.rb