r_logger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 723d35082e7b3f630046a4f597743e96b731bae9fa19c340ef4ebfd3495d0fc1
4
+ data.tar.gz: 7e7f834d310fb47ed73cde370da50891afbd08e692bbfbd41942a5ac95b1cd3c
5
+ SHA512:
6
+ metadata.gz: 13b8a3a81d3d6e6e08d42cea18c46ddb9d12cd10a28fc67e88ef590dd70777f61533837fe686f725ec1fb9cb4ad03bdbdf3fca0b44056c8704b578db5fca22ce
7
+ data.tar.gz: a3b82f9c2609fbf9498d87c096c25b39884871a87924606a1baa827b95a5d54fa670a4032404236a138c1ca366e978c62d2372642f72f75705523997667c6e89
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 ian
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # RLogger
2
+ simple way to create logger with specific name in Ruby On Rails, and it will generate log file under the `log` folder
3
+
4
+ ## Usage
5
+ above code will create log file log/first.log, and return a object that instance of ActiveSupport::Logger
6
+ ```ruby
7
+ logger = RLogger.make("first_log") # #<ActiveSupport::Logger:0x0000559df31ba5d0 ...>
8
+ logger.info "Hello RLogger"
9
+ ```
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'r_logger'
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install r_logger
26
+ ```
27
+
28
+ ## Contributing
29
+ Contribution directions go here.
30
+
31
+ ## License
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rake/testtask"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'test'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.verbose = false
11
+ end
12
+
13
+ task default: :test
data/lib/r_logger.rb ADDED
@@ -0,0 +1,33 @@
1
+ require "r_logger/version"
2
+ require "r_logger/railtie"
3
+
4
+ module RLogger
5
+ # Your code goes here...
6
+ class << self
7
+ def make(log_file)
8
+ @logger ||= {}
9
+
10
+ log_file_name = if log_file.class.in? [String, Symbol]
11
+ log_file_name = log_file.to_sym
12
+
13
+ unless log_file_name.to_s.end_with? ".log"
14
+ log_file_name = "#{log_file_name}.log"
15
+ end
16
+
17
+ "#{root_path}/#{log_file_name}"
18
+ elsif log_file.respond_to? :to_path
19
+ log_file.to_path
20
+ else
21
+ raise Exceptions::UnsupportdParamType.new("log file parameter only support 'File' or 'String' Type.")
22
+ end
23
+
24
+ # 如果已经存在日志对象,则返回已有的日志对象
25
+ @logger[log_file_name] ||= ::Logger.new(log_file_name)
26
+ end
27
+
28
+ def root_path
29
+ @root ||= "#{Rails.root}/log"
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,4 @@
1
+ module RLogger
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RLogger
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :r_logger do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: r_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ian
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.4
27
+ description: just pass a file name, it will generate the log file with specific
28
+ name
29
+ email:
30
+ - ianlynxk@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - MIT-LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/r_logger.rb
39
+ - lib/r_logger/railtie.rb
40
+ - lib/r_logger/version.rb
41
+ - lib/tasks/r_logger_tasks.rake
42
+ homepage: https://github.com/otorain/r_logger
43
+ licenses:
44
+ - MIT
45
+ metadata:
46
+ homepage_uri: https://github.com/otorain/r_logger
47
+ source_code_uri: https://github.com/otorain/r_logger
48
+ changelog_uri: https://github.com/otorain/r_logger/CHANGELOG.md
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.2.15
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: for log info to independent file simply
68
+ test_files: []