itz_logger 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 948b58ddf194add4ddf7fd1c4ac247be9fb8b1274c8f12ce4dc4c9732de3bb38
4
- data.tar.gz: '0399224bd433985e44c8c1b7bd504693def463d0a220b9fad378d8ba6626d9f9'
3
+ metadata.gz: 171611dc617d003a9b4a6a3b92202f0f529e27179cb6329866a1a257cf20e53f
4
+ data.tar.gz: 73523533ada3dd32512226c4347f33acb74ab433060a5c30b09b1f3bff56fa99
5
5
  SHA512:
6
- metadata.gz: 24c142055c1d2e32c83d419d06df47351d74f9303dd9ac4927cd4b26eaf4dad6f7387b5ba4ff7130742571cc1bc7a868a1b76099b2fc399de2b7becd1e71c6c6
7
- data.tar.gz: 9346292818619d8d28daf84c9bd24bd3e297fbd49a34f97d0409a03cd853a3da65f1e648940f9f551615ca37c2035827b3a9e15c9fb659aa69f610c3b3c4e798
6
+ metadata.gz: 32700bd7cad158abc87c8499015245c2bf8c9ef064091a529a8413192358532951bb89d3f6062d1992617c1504d04d3de91bf6d3afa39c95ab395be5806dfe90
7
+ data.tar.gz: 756ebd564719e4632c7b922af99829fa49913764ebf6d92ff1ee1422fa489f868fdafe3dbbe8c46249fc20d1b869b0276062f36613a8804365881dbf7d3d0892
data/README.md CHANGED
@@ -1,20 +1,25 @@
1
1
  # ItzLogger
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/itz_logger`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ItzLogger is the N+1 log gem. Following the rule, that at least once in a life time every programmer has to write a log gem (or lib or app ...).
4
+
5
+ This log gem supports multiple output channels:
6
+
7
+ 1. log to the terminal (stdout only)
8
+ 2. log to a file (not yet implemented)
9
+ 3. log to a RabbitMQ service (not yet implemented)
4
10
 
5
- TODO: Delete this and the text above, and describe your gem
6
11
 
7
12
  ## Installation
8
13
 
9
14
  Add this line to your application's Gemfile:
10
15
 
11
16
  ```ruby
12
- gem 'itz_logger'
17
+ gem 'itz_logger', '~> 0.2.6'
13
18
  ```
14
19
 
15
20
  And then execute:
16
21
 
17
- $ bundle
22
+ $ bundle install
18
23
 
19
24
  Or install it yourself as:
20
25
 
@@ -22,7 +27,42 @@ Or install it yourself as:
22
27
 
23
28
  ## Usage
24
29
 
25
- TODO: Write usage instructions here
30
+ The usage is straight forward. Require the gem, create an object, configure it and write logs.
31
+
32
+ ### Log to the terminal (stdout)
33
+
34
+ First things first - install the gem. Take a look in the installation section.
35
+
36
+ A simple example:
37
+
38
+ ```ruby
39
+ require 'itz_logger'
40
+
41
+ ...
42
+
43
+ # you can choose the log_level from from
44
+ # - :info
45
+ # - :warn
46
+ # - :debug
47
+ # - :verbose
48
+ log_level = :info
49
+
50
+ # you can choose the target from
51
+ # - :log_terminal
52
+ log_target = :log_terminal
53
+
54
+ # create a logger
55
+ logger = ItzLogger::Logger.new(log_level, log_target)
56
+
57
+ # now go ahead
58
+ logger.info("foo")
59
+
60
+ logger.warn("bar")
61
+
62
+ logger.debug("baz")
63
+
64
+ logger.verbose("foo bar baz")
65
+ ```
26
66
 
27
67
  ## Development
28
68
 
@@ -0,0 +1,33 @@
1
+
2
+ require_relative "./message"
3
+ require_relative "./formatter"
4
+
5
+ module ItzLogger
6
+ class LogFile
7
+
8
+ @log_level = nil
9
+
10
+ attr_reader :log_level
11
+
12
+ def initialize(
13
+ log_level = ItzLogger::MessageType::INFO,
14
+ log_file = "/tmp/logfile.log")
15
+
16
+ @log_level = log_level
17
+ end
18
+
19
+ def write(_log_level, _message)
20
+ puts "not yet implemented"
21
+ # return nil if !ItzLogger::MessageType.equals(@log_level, log_level)
22
+
23
+ # message = ItzLogger::Message.new(message, log_level)
24
+ # ItzLogger::Formatter.format(message)
25
+ end
26
+
27
+ def log_level=(log_level)
28
+ if ItzLogger::MessageType::TYPES.include?(log_level)
29
+ @log_level = log_level
30
+ end
31
+ end
32
+ end
33
+ end
@@ -8,14 +8,19 @@ module ItzLogger
8
8
 
9
9
  @log_strategy = nil
10
10
 
11
- def initialize(log_level, strategy)
12
-
13
- case strategy
14
- when ItzLogger::LogStrategy::LOG_TERMINAL
15
- @log_strategy = ItzLogger::LogTerminal.new(log_level)
16
- else
17
- @log_strategy = ItzLogger::LogTerminal.new(log_level)
18
- end
11
+ def initialize(options = {})
12
+
13
+ log_level = options.fetch(:log_level, ItzLogger::MessageType::INFO)
14
+ log_strategy = options.fetch(:log_strategy, ItzLogger::LogStrategy::LOG_TERMINAL)
15
+ _log_file = options.fetch(:log_file, "./log/logfile.log")
16
+
17
+ @log_strategy =
18
+ case log_strategy
19
+ when ItzLogger::LogStrategy::LOG_TERMINAL
20
+ ItzLogger::LogTerminal.new(log_level)
21
+ when ItzLogger::LogStrategy::LOG_FILE
22
+ ItzLogger::LogFile.new(log_level)
23
+ end
19
24
  end
20
25
 
21
26
  def write(log_level, message)
@@ -1,3 +1,3 @@
1
1
  module ItzLogger
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itz_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Schaarschmidt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-20 00:00:00.000000000 Z
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,7 @@ files:
72
72
  - itz_logger.gemspec
73
73
  - lib/itz_logger.rb
74
74
  - lib/itz_logger/formatter.rb
75
+ - lib/itz_logger/log_file.rb
75
76
  - lib/itz_logger/log_strategy.rb
76
77
  - lib/itz_logger/log_terminal.rb
77
78
  - lib/itz_logger/logger.rb