The logs can be shown as chart by kibana.
Signed-off-by: Li Yuanchao <lyc163mail(a)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..ae7e64b 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
@@ -192,6 +193,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 +511,14 @@ class MirrorMain
traverse_repodir(repodir, belong)
end
end
+
+ def new_refs_log(git_repo, nr_new_branch)
+ log = JSONLogger.new
+ log.info({
+ msg: 'new refs',
+ time: Time.now,
+ repo: git_repo,
+ nr_new_branch: nr_new_branch
+ }.to_json)
+ end
end
--
2.23.0