lib/dockerun.rb in dockerun-0.3.6 vs lib/dockerun.rb in dockerun-0.4.0

- old
+ new

@@ -1,43 +1,50 @@ # frozen_string_literal: true require 'toolrack' require 'teLogger' -require 'colorize' -require 'tty/prompt' +require 'tty/command' +require 'tty/which' require_relative "dockerun/version" +require_relative 'dockerun/dsl' -require_relative 'dockerun/command/dockerun' -require_relative 'dockerun/command/init' -require_relative 'dockerun/command/run' -require_relative 'dockerun/command/reset_image' -require_relative 'dockerun/command/run_new_container' -require_relative 'dockerun/command/remove_container' -require_relative 'dockerun/command/run_new_image' -require_relative 'dockerun/command/stop_container' +require_relative 'dockerun/cli_engine' -require_relative 'dockerun/template/template_writer' -require_relative 'dockerun/template/template_engine' - module Dockerun + include TR::CondUtils + class Error < StandardError; end # Your code goes here... - def self.udebug(msg) - logger.tdebug(:dockerun, msg) if is_user_debug_on? - end - - def self.logger + def self.logger(tag = nil, &block) if @_logger.nil? - @_logger = TeLogger::Tlogger.new + drLogout = ENV["DR_LOGOUT"] + if is_empty?(drLogout) + @_logger = TeLogger::Tlogger.new('dockerun.log',5, 5*1024*1024) + else + @_logger = TeLogger::Tlogger.new(drLogout, 5, 5*1024*1024) + end end - @_logger - end - def self.is_user_debug_on? - val = ENV["DOCKERUN_DEBUG"] - (not val.nil? and val == "true") + if block + if not_empty?(tag) + @_logger.with_tag(tag, &block) + else + @_logger.with_tag(@_logger.tag, &block) + end + else + if is_empty?(tag) + @_logger.tag = :dockerun + @_logger + else + # no block but tag is given? hmm + @_logger.tag = tag + @_logger + end + end end + + end