singleton-client-test 0.7.7.1 → 0.7.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- require 'logger'
5
- require 'time'
6
-
7
- module SgtnClient
8
-
9
- # Include Logging module to provide logger functionality.
10
- # == Configure logger
11
- # Logging.logger = Logger.new(STDERR)
12
- #
13
- # == Example
14
- # include Logger
15
- # logger.info "Debug message"
16
- module Logging
17
-
18
- # Get logger object
19
- def logger
20
- @logger ||= Logging.logger
21
- end
22
-
23
- def log_event(message, &block)
24
- start_time = Time.now
25
- block.call
26
- ensure
27
- logger.info sprintf("[%.3fs] %s", Time.now - start_time, message)
28
- end
29
-
30
- class << self
31
-
32
- # Get or Create configured logger based on the default environment configuration
33
- def logger
34
- @logger ||= Logger.new(STDERR)
35
- end
36
-
37
- # Set logger directly and clear the loggers cache.
38
- # === Attributes
39
- # * <tt>logger</tt> -- Logger object
40
- # === Example
41
- # Logging.logger = Logger.new(STDERR)
42
- def logger=(logger)
43
- @logger = logger
44
- if Config.config.mode.eql? 'live' and @logger.level == Logger::DEBUG
45
- @logger.warn "DEBUG log level not allowed in live mode for security of confidential information. Changing log level to INFO..."
46
- @logger.level = Logger::INFO
47
- end
48
- end
49
-
50
- end
51
- end
52
-
53
- end