redis_syslog 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 924172dfbfc65f5e6bd0c4f4e7ff69cfb9fe7145
4
+ data.tar.gz: 5d4da4acccbb0f167f0bedf72bb60bec3bd44623
5
+ SHA512:
6
+ metadata.gz: f95f0d7319a35bffc89c8845601645ed775cab9602af4bd9293168d977e9db3f0d0e7eb9e7270734376a0400831990c76ba37a7c3561caa338f73f0098c19a5a
7
+ data.tar.gz: 32096759a83f81ee940a79b4925d34a9a38ae32c1086faaf2568ba4ab8d7e23698754761377fb5a6117eb8e3a7d8adbc2219f8b0e64d80892d2cdbb8a1a57bee
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redis_syslog.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <2014> <Fittr®>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 seo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ RedisSyslog
2
+ ===================
3
+ RedisSyslog is a simple ruby gem that allows ruby to log directly to redis in a high performance environment. We do rely on [redis-rb](https://github.com/redis/redis-rb "redis-rb"), so go grab a copy if you haven't already! We originally wrote for Fittr® because our remote scripts needed to be easily checked to see if they were working or not. We now deploy RedisSyslog as a general purpose logging utility where our many services are able to concurrently log to.
4
+
5
+ Let's get you started real quick.
6
+ -------------
7
+
8
+ 1. Include the gem in your Gemfile
9
+ ```ruby
10
+ gem 'redis_syslog'
11
+ ```
12
+
13
+ 2. Initalize an object. Or as many as you'd like! Thread safety, hurray!
14
+ ```ruby
15
+ #Create a redis-rb intsance
16
+ @redis = Redis.new
17
+
18
+ #Create an instance of RedisSyslog
19
+ @logger = RedisSyslog.new redisrb: @redis, namespace: "com.fittr.periodic"
20
+ ```
21
+
22
+ 3. Profit
23
+ ```ruby
24
+ #Write a new entry
25
+ @logger.write "This is my message"
26
+
27
+ #Get last 1 entry
28
+ @logger.last_n_entries(1) #[{:time=>TimeClass, :message => "This is my message"]
29
+
30
+ #Delete all entries
31
+ @logger.delete!
32
+ ```
33
+
34
+ That's it. That's the entire API.
35
+ ------------
36
+ How is it stored? Simple. Each namespace uses the one key with a redis sorted set. The key follows this format.
37
+
38
+ `` redis_syslog://#{namespace} ``
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,40 @@
1
+ require "redis_syslog/version"
2
+
3
+ class RedisSyslog::RedisSyslog
4
+ PREFIX = "redis_syslog://"
5
+
6
+ def self.list_used_namespaces
7
+ #Return a list of used namespaces
8
+ end
9
+
10
+ def initialize(redisrb:, namespace:)
11
+ @redis = redisrb
12
+ @namespace = namespace
13
+ end
14
+
15
+ #This is the actual list key
16
+ def _key
17
+ return "#{PREFIX}#{@namespace}"
18
+ end
19
+
20
+ def delete!
21
+ @redis.del _key
22
+ end
23
+
24
+ def last_n_entries n
25
+ raise "n cannot be 0" unless n > 0
26
+ #Return the last N entries of this log
27
+ results = @redis.zrevrange _key, 0, n-1, :with_scores => true
28
+ results = results.map{|e| {:time => Time.at(e[1]), :message => e[0]} }
29
+ end
30
+
31
+ def write message
32
+ @redis.zadd _key, Time.now.to_i, message
33
+ end
34
+ end
35
+
36
+ module RedisSyslog
37
+ def self.new(redisrb:, namespace:)
38
+ return RedisSyslog.new redisrb: redisrb, namespace: namespace
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module RedisSyslog
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'redis_syslog/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "redis_syslog"
8
+ spec.version = RedisSyslog::VERSION
9
+ spec.authors = ["Seo Townsend"]
10
+ spec.email = ["seotownsend@icloud.com"]
11
+ spec.summary = %q{A very simple and high performance universal logging utility for ruby and redis.}
12
+ spec.description = %q{RedisSyslog is a simple ruby gem that allows ruby to log directly to redis in a high performance environment. We do rely on redis-rb, so go grab a copy if you haven't already! We originally wrote for Fittr® because our remote scripts needed to be easily checked to see if they were working or not. We now deploy RedisSyslog as a general purpose logging utility where our many services are able to concurrently log to.}
13
+ spec.homepage = "https://github.com/GndFloor/RedisSyslog"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis_syslog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Seo Townsend
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: RedisSyslog is a simple ruby gem that allows ruby to log directly to
42
+ redis in a high performance environment. We do rely on redis-rb, so go grab a copy
43
+ if you haven't already! We originally wrote for Fittr® because our remote scripts
44
+ needed to be easily checked to see if they were working or not. We now deploy RedisSyslog
45
+ as a general purpose logging utility where our many services are able to concurrently
46
+ log to.
47
+ email:
48
+ - seotownsend@icloud.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - ".gitignore"
54
+ - Gemfile
55
+ - LICENSE
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/redis_syslog.rb
60
+ - lib/redis_syslog/version.rb
61
+ - redis_syslog.gemspec
62
+ homepage: https://github.com/GndFloor/RedisSyslog
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A very simple and high performance universal logging utility for ruby and
86
+ redis.
87
+ test_files: []
88
+ has_rdoc: