s3_logger 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in s3_logger.gemspec
4
+ gemspec
@@ -0,0 +1,53 @@
1
+ Why use S3 for logging?
2
+ =======================
3
+ I love [Heroku](http://heroku.com) and deploy there all the time - its a great way to work with Ruby and web applications. But one of the "features" of Heroku is that its a read-only file system, which can make logging clumsy.
4
+
5
+ The best way I've found to deal with this situation is to shove all your logging duties off to S3. In fact, I have done this so often that I extracted the code I used to copy/paste from project to project and that's the point of this gem.
6
+
7
+ Its built using the [EasyS3](https://github.com/jonallured/easy_s3) gem (which itself is built on the [Ruby S3 Gem](https://github.com/marcel/aws-s3)), so you have to be good with that.
8
+
9
+ Install
10
+ -------
11
+ Just use the `gem` command:
12
+
13
+ gem install s3_logger
14
+
15
+ If you don't have `easy_s3` or `aws-s3`, they will be installed as well.
16
+
17
+ Setup
18
+ -----
19
+ S3Logger can't do anything until you [setup EasyS3](https://github.com/jonallured/easy_s3), so go check out that documentation first. Then, you should probably set two more environment variables:
20
+
21
+ S3_LOGGER_FILE => your default log file
22
+ S3_LOGGER_PATH => your default log path
23
+
24
+ You don't have to setup these defaults, but if you don't you'll have to explicitly set them every time and not having to do that is the whole point of this gem!
25
+
26
+ Methods
27
+ -------
28
+ There is really just one method:
29
+
30
+ log(message, timestamp_flag=false, file=ENV['S3_LOGGER_FILE'], path=ENV['S3_LOGGER_PATH'])
31
+
32
+ With four attributes:
33
+
34
+ data => the actual log message, required
35
+ timestamp_flag => prepends Time.now to message when true; optional; defaults to false
36
+ file => the file to write our message to; optional; default to the ENV variable
37
+ path => the path to our file; optional; defaults to the ENV variable
38
+
39
+ Usage
40
+ -----
41
+ S3Logger supports a few different uses:
42
+
43
+ S3Logger.log('some smart log message')
44
+ # => writes this message to the default log file at the default path with no timestamp
45
+
46
+ S3Logger.log('some smart log message', true)
47
+ # => writes this message to the default log file at the default path with a timestamp
48
+
49
+ S3Logger.log('some smart log message', false, 'debug.log')
50
+ # => writes this message to the debug.log file at the default path with no timestamp
51
+
52
+ S3Logger.log('some smart log message', true, 'debug.log', 'debug/log/path/')
53
+ # => writes this message to the debug.log file using debug/log/path/ as the path with a timestamp
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,10 @@
1
+ require 'easy_s3'
2
+
3
+ module S3Logger
4
+ def self.log(message, timestamp_flag=false, file=ENV['S3_LOGGER_FILE'], path=ENV['S3_LOGGER_PATH'])
5
+ message += "\n"
6
+ message = "[#{Time.now}]\n" + message if timestamp_flag
7
+ full_path = path + file
8
+ EasyS3.exists?(full_path) ? EasyS3.append(full_path, message) : EasyS3.write(full_path, message)
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module S3Logger
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/s3_logger/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "s3_logger"
6
+ s.version = S3Logger::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Jon Allured"]
9
+ s.email = ["jon.allured@me.com"]
10
+ s.homepage = "http://rubygems.org/gems/s3_logger"
11
+ s.summary = "simple logging to S3 using the easy_s3 gem"
12
+ s.description = "aims to simplify the task of logging by making some assumptions and using the easy_s3 gem"
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
18
+ s.require_path = 'lib'
19
+
20
+ s.add_dependency "easy_s3"
21
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: s3_logger
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jon Allured
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-03 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: easy_s3
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: aims to simplify the task of logging by making some assumptions and using the easy_s3 gem
36
+ email:
37
+ - jon.allured@me.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README.md
48
+ - Rakefile
49
+ - lib/s3_logger.rb
50
+ - lib/s3_logger/version.rb
51
+ - s3_logger.gemspec
52
+ has_rdoc: true
53
+ homepage: http://rubygems.org/gems/s3_logger
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 23
76
+ segments:
77
+ - 1
78
+ - 3
79
+ - 6
80
+ version: 1.3.6
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.3.7
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: simple logging to S3 using the easy_s3 gem
88
+ test_files: []
89
+