yajl 0.2.2 → 0.3.2
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 +4 -4
- data/README.markdown +4 -2
- data/lib/yajl.rb +31 -9
- data/lib/yajl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f16a11b1d6b326240447f36ba5b6396c9a5fe927
|
|
4
|
+
data.tar.gz: 080e4b796b36836db9ef1eab90f9712103bc8b67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db297ea29f8ce8fe70d01b0ddff9496748f20f7bd708315bc06842878c65f5533e29c2703383d1766532998eefe9e6615452f94ceb3ad32eb71ee81a128e9633
|
|
7
|
+
data.tar.gz: a810f693150d64d27ad6c9b593ba84c4e1418bc08fc3b7d103e5d8f741f869739c20535a96b220ca24e5bf5be008170d1cc8eaf5e4d2f7c7675223434a90dad4
|
data/README.markdown
CHANGED
|
@@ -9,6 +9,7 @@ without screwing around, and I want to be able to easily log text.
|
|
|
9
9
|
|
|
10
10
|
1. Tests. I guess. Maybe.
|
|
11
11
|
2. Maybe rewrite this in [Nim](http://nim-lang.org/) and wrap it in the Ruby FFI. I'd have to be logging a *lot* to justify it though.
|
|
12
|
+
3. Maybe make it Windows friendly. (Not sure how to handle newlines for Windows).
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
@@ -101,7 +102,8 @@ Which sets the `progname` attribute.
|
|
|
101
102
|
By default logs are stored in `~/logs` with a very sensible
|
|
102
103
|
logger name. If even one person wants the ability to change the
|
|
103
104
|
filename that is set I'll add the support to do so. Right now it
|
|
104
|
-
looks like this
|
|
105
|
+
looks like this (Where `yajl` would be the name of whatever git
|
|
106
|
+
repo you are using):
|
|
105
107
|
|
|
106
108
|
`/home/zach/logs/zach@Lux.yajl.log`
|
|
107
109
|
|
|
@@ -110,7 +112,7 @@ or like this:
|
|
|
110
112
|
`/home/zach/logs/zach@Lux.yajl.log.1`
|
|
111
113
|
|
|
112
114
|
If there are multiple running processes (just like the normal Ruby
|
|
113
|
-
|
|
115
|
+
logger).
|
|
114
116
|
|
|
115
117
|
Note, it gets the name of the project from your Git project name.
|
|
116
118
|
If you don't use Git let me know and I'll make this toggleable too.
|
data/lib/yajl.rb
CHANGED
|
@@ -4,9 +4,36 @@ require "securerandom"
|
|
|
4
4
|
|
|
5
5
|
require "yajl/version"
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
def project
|
|
8
|
+
result = `git rev-parse --show-toplevel`.chomp
|
|
9
|
+
message = "logger only works within a git project"
|
|
10
|
+
raise message if result == ""
|
|
11
|
+
|
|
12
|
+
result
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class YajlLogger < Logger
|
|
16
|
+
|
|
17
|
+
%w{ warn info debug fatal error unknown }
|
|
18
|
+
.each do |method_name|
|
|
19
|
+
define_method(method_name) do |message|
|
|
20
|
+
sender = caller[0].split(":")[0]
|
|
21
|
+
path = sender.split("/")
|
|
22
|
+
project_depth = project.split("/").size
|
|
23
|
+
|
|
24
|
+
if path[0..project_depth-1].join("/") == project
|
|
25
|
+
path = path[project_depth..-1]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
progname = path.join("/")
|
|
29
|
+
super(progname) { message }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# I don't want header lines
|
|
8
34
|
def add_log_header(file)
|
|
9
35
|
end
|
|
36
|
+
|
|
10
37
|
end
|
|
11
38
|
|
|
12
39
|
module Yajl
|
|
@@ -18,16 +45,11 @@ module Yajl
|
|
|
18
45
|
user = `whoami`.chomp
|
|
19
46
|
hostname = `hostname`.chomp
|
|
20
47
|
|
|
21
|
-
project = `git rev-parse --show-toplevel`.chomp
|
|
22
|
-
message = "logger only works within a git project"
|
|
23
|
-
raise message if project == ""
|
|
24
|
-
|
|
25
48
|
`mkdir -p #{log_directory}`
|
|
49
|
+
project_name = project.split("/")[-1]
|
|
26
50
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
filename = File.expand_path("~/logs/#{user}@#{hostname}.#{project}.log")
|
|
30
|
-
logger = Logger.new(filename)
|
|
51
|
+
filename = File.expand_path("#{log_directory}/#{user}@#{hostname}.#{project_name}.log")
|
|
52
|
+
logger = YajlLogger.new(filename)
|
|
31
53
|
|
|
32
54
|
logger.level = Logger::INFO
|
|
33
55
|
logger.formatter = proc do |severity, datetime, progname, message|
|
data/lib/yajl/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yajl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zach Aysan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-08-
|
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|