The logs can be shown as chart by kibana.
Signed-off-by: Li Yuanchao lyc163mail@163.com --- lib/git_mirror.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index bb0c9f9..53c9e59 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -11,6 +11,7 @@ require 'priority_queue' require 'English' require 'elasticsearch' require_relative 'constants.rb' +require_relative 'json_logger.rb'
# worker threads class GitMirror @@ -106,6 +107,7 @@ class MirrorMain @git_info = {} @defaults = {} @git_queue = Queue.new + @log = JSONLogger.new @es_client = Elasticsearch::Client.new(url: "http://#%7BES_HOST%7D:#%7BES_PORT%7D") clone_upstream_repo load_fork_info @@ -192,6 +194,7 @@ class MirrorMain
feedback_info[:new_refs] = new_refs send_message(feedback_info) + new_refs_log(git_repo, new_refs[:heads].length) end
def do_push(fork_key) @@ -509,4 +512,13 @@ class MirrorMain traverse_repodir(repodir, belong) end end + + def new_refs_log(git_repo, nr_new_branch) + @log.info({ + msg: 'new refs', + time: Time.now, + repo: git_repo, + nr_new_branch: nr_new_branch + }.to_json) + end end