ashleyw-simplelogger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +46 -0
- data/lib/simplelogger.rb +21 -0
- metadata +54 -0
data/README.markdown
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
Intro
|
2
|
+
=====
|
3
|
+
|
4
|
+
SimpleLogger is as simple as you can get — the class is just over 20 lines, and it could be rewritten in 5 minutes by anyone who knows the basics of Ruby. It was created out of a personal need for ultra simple logging, to stop myself from randomly squeezing in `puts my_var` everywhere when debugging! (Plus I thought it would be worth quickly creating instead of learning the basic quirks of the native Logger Ruby class)
|
5
|
+
|
6
|
+
Usage
|
7
|
+
=====
|
8
|
+
require 'rubygems'
|
9
|
+
require 'simplelogger'
|
10
|
+
|
11
|
+
LOG = SimpleLogger.new("log.txt")
|
12
|
+
|
13
|
+
LOG.info("Testing") #=> ---> Testing (30/12 @ 11:59pm)
|
14
|
+
LOG.warn("Testing") #=> >>>> Testing (30/12 @ 11:59pm)
|
15
|
+
LOG.error("Testing") #=> !!!> Testing (30/12 @ 11:59pm)
|
16
|
+
|
17
|
+
The output will be sent to the "log.txt" file, which you can ``tail -f log.txt`` in an Unix environment.
|
18
|
+
|
19
|
+
Install
|
20
|
+
=======
|
21
|
+
|
22
|
+
gem install ashleyw-simplelogger --source http://gems.github.com
|
23
|
+
|
24
|
+
The MIT License
|
25
|
+
===============
|
26
|
+
|
27
|
+
Copyright (c) 2008 Ashley Williams
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
"Software"), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
43
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
44
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
45
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
46
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/simplelogger.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class SimpleLogger
|
2
|
+
def initialize(file = "log.txt")
|
3
|
+
@file = file
|
4
|
+
end
|
5
|
+
|
6
|
+
def warn(message)
|
7
|
+
File.open(@file, "a") {|f| f.write(">>>> #{message} (#{time})\n") }
|
8
|
+
end
|
9
|
+
|
10
|
+
def info(message)
|
11
|
+
File.open(@file, "a") {|f| f.write("---> #{message} (#{time})\n") }
|
12
|
+
end
|
13
|
+
|
14
|
+
def error(message)
|
15
|
+
File.open(@file, "a") {|f| f.write("!!!> #{message} (#{time})\n") }
|
16
|
+
end
|
17
|
+
|
18
|
+
def time
|
19
|
+
Time.now.strftime("%d/%M @ %I:%M%p").downcase
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ashleyw-simplelogger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ashley Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-22 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ParseConfig provides simple parsing of standard *nix style config files.
|
17
|
+
email: a.j.r.williams@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.markdown
|
26
|
+
- lib/simplelogger.rb
|
27
|
+
has_rdoc: false
|
28
|
+
homepage:
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: "0"
|
39
|
+
version:
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
requirements: []
|
47
|
+
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.2.0
|
50
|
+
signing_key:
|
51
|
+
specification_version: 2
|
52
|
+
summary: SimpleLogger provides an ultra simple logging system.
|
53
|
+
test_files: []
|
54
|
+
|