koa-utils 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/koa-utils/logger.rb +9 -5
- data/lib/koa-utils/sequel-logger.rb +33 -0
- data/lib/koa-utils.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6b0f306929583b66a794b3ab28a236b4033426
|
4
|
+
data.tar.gz: 0e8c972e56b535beb8cd26b52a4983eea9b6f08f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be1959550ee1e0cc8c5c71374eb8fc962ae6a3dc83d649ea9cf362f89dbcaa5ce6187f9b652de90c8ba78a98cac935bcd517998216afb71e8a0aa55526fd0770
|
7
|
+
data.tar.gz: 42fb3008d33dc0e9af75354e913485254fb95173a55bc2a2035d381e258407c416fc1e6a1b598b8c0d8c0ecf157d76fd76bc1712d68a056625301932a51cb174
|
data/lib/koa-utils/logger.rb
CHANGED
@@ -2,12 +2,16 @@ $stdout.sync = true
|
|
2
2
|
|
3
3
|
module KOAUtils::Logger
|
4
4
|
|
5
|
-
def self.
|
5
|
+
def self.appname
|
6
|
+
@prefix ||= ENV['APP_NAME'].downcase if ENV['APP_NAME']
|
6
7
|
if defined? ::Rails
|
7
|
-
Rails.application.class.parent_name.downcase+"."
|
8
|
-
else
|
9
|
-
name
|
8
|
+
@prefix ||= Rails.application.class.parent_name.downcase+"."
|
10
9
|
end
|
10
|
+
@prefix ||= ""
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.prefix(name)
|
14
|
+
appname+name
|
11
15
|
end
|
12
16
|
|
13
17
|
def self.librato_log(type, name, val, data)
|
@@ -45,4 +49,4 @@ module KOAUtils::Logger
|
|
45
49
|
s << [tup.first, tup.last].join("=") << " "
|
46
50
|
end
|
47
51
|
end
|
48
|
-
end
|
52
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module KOAUtils
|
2
|
+
if defined?(::Sequel)
|
3
|
+
module ::Sequel
|
4
|
+
class Database
|
5
|
+
def log_yield(sql, args=nil)
|
6
|
+
sql = "#{sql}; #{args.inspect}" if args
|
7
|
+
t0 = Time.now
|
8
|
+
begin
|
9
|
+
yield
|
10
|
+
rescue => e
|
11
|
+
log_exception(e, sql)
|
12
|
+
raise
|
13
|
+
ensure
|
14
|
+
t1 = Time.now
|
15
|
+
log_duration(Integer((t1-t0)*1000), sql) unless e
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def log_duration(t, sql)
|
20
|
+
Logger.measure("sequel-latency", t, source: action(sql))
|
21
|
+
end
|
22
|
+
|
23
|
+
def log_exception(e, sql)
|
24
|
+
Logger.log(error: "sequel-exception", class: e.class)
|
25
|
+
end
|
26
|
+
|
27
|
+
def action(sql)
|
28
|
+
sql[/(\w+){1}/].downcase
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/koa-utils.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koa-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Rykwalder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gem of tools for KOA
|
14
|
-
email: eric@
|
14
|
+
email: eric@koa.la
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- lib/koa-utils/kik.rb
|
21
21
|
- lib/koa-utils/logger.rb
|
22
22
|
- lib/koa-utils/rack-request-timer.rb
|
23
|
+
- lib/koa-utils/sequel-logger.rb
|
23
24
|
- lib/koa-utils.rb
|
24
25
|
homepage: http://github.com/albumatic
|
25
26
|
licenses:
|
@@ -41,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
42
|
version: '0'
|
42
43
|
requirements: []
|
43
44
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.
|
45
|
+
rubygems_version: 2.0.6
|
45
46
|
signing_key:
|
46
47
|
specification_version: 4
|
47
48
|
summary: KOA tools
|