Commit 0523b4265bb19bfff15c6a435dd52ffd6a5683f8
1 parent
49039103
Exists in
master
and in
4 other branches
Application logger
Showing
10 changed files
with
86 additions
and
20 deletions
Show diff stats
app/assets/javascripts/admin.js.coffee
app/assets/javascripts/application.js
app/assets/stylesheets/sections/nav.scss
app/observers/project_observer.rb
| ... | ... | @@ -4,6 +4,18 @@ class ProjectObserver < ActiveRecord::Observer |
| 4 | 4 | end |
| 5 | 5 | |
| 6 | 6 | def after_destroy(project) |
| 7 | + log_info("Project \"#{project.name}\" was removed") | |
| 8 | + | |
| 7 | 9 | project.destroy_repository |
| 8 | 10 | end |
| 11 | + | |
| 12 | + def after_create project | |
| 13 | + log_info("#{project.owner.name} created a new project \"#{project.name}\"") | |
| 14 | + end | |
| 15 | + | |
| 16 | + protected | |
| 17 | + | |
| 18 | + def log_info message | |
| 19 | + Gitlab::AppLogger.info message | |
| 20 | + end | |
| 9 | 21 | end | ... | ... |
app/observers/user_observer.rb
| 1 | 1 | class UserObserver < ActiveRecord::Observer |
| 2 | 2 | def after_create(user) |
| 3 | + log_info("User \"#{user.name}\" (#{user.email}) was created") | |
| 4 | + | |
| 3 | 5 | Notify.new_user_email(user.id, user.password).deliver |
| 4 | 6 | end |
| 7 | + | |
| 8 | + def after_destroy user | |
| 9 | + log_info("User \"#{user.name}\" (#{user.email}) was removed") | |
| 10 | + end | |
| 11 | + | |
| 12 | + protected | |
| 13 | + | |
| 14 | + def log_info message | |
| 15 | + Gitlab::AppLogger.info message | |
| 16 | + end | |
| 5 | 17 | end | ... | ... |
app/views/admin/logs/show.html.haml
| 1 | -.file_holder#README | |
| 2 | - .file_title | |
| 3 | - %i.icon-file | |
| 4 | - githost.log | |
| 5 | - .file_content.logs | |
| 6 | - %ol | |
| 7 | - - Gitlab::Logger.read_latest.each do |line| | |
| 8 | - %li | |
| 9 | - %p= line | |
| 1 | +%ul.nav.nav-tabs.log-tabs | |
| 2 | + %li.active | |
| 3 | + = link_to "githost.log", "#githost", 'data-toggle' => 'tab' | |
| 4 | + %li | |
| 5 | + = link_to "application.log", "#application", 'data-toggle' => 'tab' | |
| 6 | +.tab-content | |
| 7 | + .tab-pane.active#githost | |
| 8 | + .file_holder#README | |
| 9 | + .file_title | |
| 10 | + %i.icon-file | |
| 11 | + githost.log | |
| 12 | + .file_content.logs | |
| 13 | + %ol | |
| 14 | + - Gitlab::GitLogger.read_latest.each do |line| | |
| 15 | + %li | |
| 16 | + %p= line | |
| 17 | + .tab-pane#application | |
| 18 | + .file_holder#README | |
| 19 | + .file_title | |
| 20 | + %i.icon-file | |
| 21 | + application.log | |
| 22 | + .file_content.logs | |
| 23 | + %ol | |
| 24 | + - Gitlab::AppLogger.read_latest.each do |line| | |
| 25 | + %li | |
| 26 | + %p= line | ... | ... |
lib/gitlab/backend/gitolite_config.rb
| ... | ... | @@ -58,18 +58,22 @@ module Gitlab |
| 58 | 58 | end |
| 59 | 59 | end |
| 60 | 60 | rescue PullError => ex |
| 61 | - Gitlab::Logger.error("Pull error -> " + ex.message) | |
| 61 | + log("Pull error -> " + ex.message) | |
| 62 | 62 | raise Gitolite::AccessDenied, ex.message |
| 63 | 63 | |
| 64 | 64 | rescue PushError => ex |
| 65 | - Gitlab::Logger.error("Push error -> " + " " + ex.message) | |
| 65 | + log("Push error -> " + " " + ex.message) | |
| 66 | 66 | raise Gitolite::AccessDenied, ex.message |
| 67 | 67 | |
| 68 | 68 | rescue Exception => ex |
| 69 | - Gitlab::Logger.error(ex.class.name + " " + ex.message) | |
| 69 | + log(ex.class.name + " " + ex.message) | |
| 70 | 70 | raise Gitolite::AccessDenied.new("gitolite timeout") |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | + def log message | |
| 74 | + Gitlab::GitLogger.error(message) | |
| 75 | + end | |
| 76 | + | |
| 73 | 77 | def destroy_project(project) |
| 74 | 78 | FileUtils.rm_rf(project.path_to_repo) |
| 75 | 79 | conf.rm_repo(project.path) | ... | ... |
lib/gitlab/logger.rb
| ... | ... | @@ -9,17 +9,13 @@ module Gitlab |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | 11 | def self.read_latest |
| 12 | - path = Rails.root.join("log/githost.log") | |
| 12 | + path = Rails.root.join("log", file_name) | |
| 13 | 13 | self.build unless File.exist?(path) |
| 14 | 14 | logs = File.read(path).split("\n") |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | def self.build |
| 18 | - new(File.join(Rails.root, "log/githost.log")) | |
| 18 | + new(File.join(Rails.root, "log", file_name)) | |
| 19 | 19 | end |
| 20 | - | |
| 21 | - def format_message(severity, timestamp, progname, msg) | |
| 22 | - "#{timestamp.to_s(:long)} -> #{severity} -> #{msg}\n" | |
| 23 | - end | |
| 24 | 20 | end |
| 25 | 21 | end | ... | ... |