lib/ccrypto.rb in ccrypto-0.1.3 vs lib/ccrypto.rb in ccrypto-0.2.0

- old
+ new

@@ -24,11 +24,20 @@ require_relative 'ccrypto/secret_key' require_relative 'ccrypto/x509_cert' require_relative 'ccrypto/x509_csr' +require_relative 'ccrypto/digest_matcher' +require_relative 'ccrypto/in_memory_record' + +require_relative 'ccrypto/keystore' + +require_relative 'ccrypto/capability' + module Ccrypto + include TR::CondUtils + class Error < StandardError; end class CcryptoProviderException < StandardError; end class DigestEngineException < StandardError; end class KDFEngineException < StandardError; end @@ -56,7 +65,39 @@ class KeyBundleStorageException < StandardError; end # Your code goes here... Root_OID = ["2","0","18"] + + def self.logger(tag = nil, &block) + if @_logger.nil? + @_logger = TeLogger::Tlogger.new + end + + 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 = :CryptoJava + @_logger + else + # no block but tag is given? hmm + @_logger.tag = tag + @_logger + end + end + + end + + def self.if_detail_debug(msg) + logger.tdebug(:ccrypto_detail_debug, msg) if is_detail_debug_on? + end + + def self.is_detail_debug_on? + ENV['CCRYPTO_DEBUG'] == "true" + end end