dino_utils 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ab5c8fbe02cb004a42b209fc0689479fb20df45
4
- data.tar.gz: c8fe073d99c87bc10ab3dc3a5b08e037b80af009
3
+ metadata.gz: 653063884efa9f611e2b20389eba764783a85fa3
4
+ data.tar.gz: 1cc97d7d8479d73808b0cc272c7aae83154683fc
5
5
  SHA512:
6
- metadata.gz: f8d68bc23f3d151763af474798f8dccf64d93f13b6e68a665a8cdf1f35eb810c47de0329fffb3029a027b97cf7fe822163d15274b94cd6d7f18511b0d0bfaa5b
7
- data.tar.gz: 5ab6f9dceb04eab1bb4765b1008a43e1478c8de45d719ededd9f2add8abec68709447337bc1b1b25f7956be0bbfbba1570aecad29d39e6148d2611f4397549e9
6
+ metadata.gz: c9544932dfb309d94835aa3983d51abfbdd96ca74b7da292f7db81cf366497f90a8bd9bfe7e2fc63ac5a318723bad1a0950e6c5576096482efc6cdbb23d597b8
7
+ data.tar.gz: 98f2f4d55e96cd846dc43ddda31783d40ec93002c7a4916ba156ae2c8b124e57876aa74974c5535d3344e671d02ca170c456d24e0b4bebee63f1ac613863c6c4
@@ -1,3 +1,3 @@
1
1
  module DinoUtils
2
- VERSION = "0.1.14".freeze
2
+ VERSION = "0.1.15".freeze
3
3
  end
data/lib/tn/logger.rb ADDED
@@ -0,0 +1,66 @@
1
+ require 'syslog/logger'
2
+ require 'json'
3
+
4
+ module TN
5
+ # Logs json to syslog.
6
+ # Automatically delegates stuff to the syslog logger.
7
+ # Use like:
8
+ # TangaServices.logger.open('my_application_name')
9
+ # TangaServices.logger.info({message: "I'm interesting data"})
10
+ # TangaServices.logger.error({message: "i crashed"})
11
+ class Logger < Syslog::Logger
12
+ def self.application_name=(application_name)
13
+ @application_name = application_name
14
+ end
15
+
16
+ def self.logger
17
+ @logger || Syslog::Logger.new((@application_name || 'unknown'), Syslog::LOG_LOCAL7)
18
+ end
19
+
20
+ def self.debug(hash)
21
+ log(:debug, hash)
22
+ end
23
+
24
+ def self.info(hash)
25
+ log(:info, hash)
26
+ end
27
+
28
+ def self.write(message)
29
+ log(:info, message: message)
30
+ end
31
+ class << self
32
+ alias :<< :write
33
+ end
34
+
35
+ def self.warn(hash)
36
+ log(:warn, hash)
37
+ end
38
+
39
+ def self.error(hash)
40
+ log(:error, hash)
41
+ end
42
+
43
+ def self.fatal(hash)
44
+ log(:fatal, hash)
45
+ end
46
+
47
+ def self.log(level, hash)
48
+ unless hash.is_a?(Hash)
49
+ hash = { object: hash }
50
+ end
51
+
52
+ fail ArgumentError, 'we just log hashes' unless hash.is_a?(Hash)
53
+ data = { level: level, object: hash }
54
+ logger.send(level, data.to_json)
55
+ end
56
+
57
+ def self.method_missing(method, *args, &block)
58
+ logger.send(method, *args, &block)
59
+ end
60
+ end
61
+
62
+ # Convience access to logger
63
+ def self.logger
64
+ Logger
65
+ end
66
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dino_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Van Dyk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -161,6 +161,7 @@ files:
161
161
  - lib/tn/advisory_lock.rb
162
162
  - lib/tn/csv_builder.rb
163
163
  - lib/tn/http.rb
164
+ - lib/tn/logger.rb
164
165
  - lib/tn/temp_file.rb
165
166
  homepage: https://github.com/tanga/dino_utils
166
167
  licenses: