Permalink
Browse files

l2met log formatting

  • Loading branch information...
1 parent c896e2a commit 0eef18015bffd52480b63e4be5349324107ff69f @rwdaigle committed Oct 5, 2012
@@ -13,5 +13,6 @@ def create
user = User.authenticate(request.env['omniauth.auth'])
log_in_user(user.id)
redirect_to search_gists_path
+ log({ns: self, fn: __method__, measure: true, at: 'login'}, user)
end
end
View
@@ -35,19 +35,20 @@ def import(gh_gist)
}
if(existing_gist = where(gh_id: gh_id).first)
- log({ns: self, fn: __method__}, user, existing_gist)
+ log({ns: self, fn: __method__, measure: true, at: 'gist-imported'}, user, existing_gist)
existing_gist.update_attributes(attributes)
existing_gist
else
new_gist = create(attributes)
- log({ns: self, fn: __method__}, user, new_gist)
+ log({ns: self, fn: __method__, measure: true, at: 'gist-created'}, user, new_gist)
new_gist
end
end
def search(user, q)
q = q.blank? ? '*' : q
- log({ns: self, fn: __method__, query: q}, user) do
+ log({ns: self, fn: __method__, query: q, measure: true, at: 'search'}, user)
+ log({ns: self, fn: __method__, query: q, measure: true}, user) do
tire.search do
query { string q }
sort { by :gh_created_at, 'desc' }
@@ -27,7 +27,7 @@ def fetch_user(user_id)
# Make sure have all gist stubs imported
def fetch_gists(gh, user)
- log({ns: self, fn: __method__}, user) do
+ log({ns: self, fn: __method__, measure: true}, user) do
gh.gists.each do |gh_gist|
Gist.import(gh_gist)
end
@@ -36,7 +36,7 @@ def fetch_gists(gh, user)
# Fetch individual gists from API to get file contents
def fetch_files(gh, user)
- log({ns: self, fn: __method__}, user) do
+ log({ns: self, fn: __method__, measure: true}, user) do
user.gists.pluck(:gh_id).each do |gh_gist_id|
GistFile.import(gh.gist(gh_gist_id))
end
View
@@ -16,12 +16,12 @@ def authenticate(auth)
}
if(existing_user = User.where(gh_id: auth.uid).first)
- log({ns: self, fn: __method__}, existing_user)
+ log({ns: self, fn: __method__, measure: true, at: 'user-authenticated'}, existing_user)
existing_user.update_attributes(attributes)
existing_user
else
new_user = User.create(attributes)
- log({ns: self, fn: __method__}, new_user)
+ log({ns: self, fn: __method__, measure: true, at: 'user-created'}, new_user)
new_user
end
end
@@ -34,6 +34,10 @@ def log_data_from(*segments)
end
end
+
+ def log(*segments, &block)
+ self.class.log(*segments, &block)
+ end
end
class Hash

0 comments on commit 0eef180

Please sign in to comment.