{"action":"created","comment":{"url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/comments/155641301","pull_request_review_id":81993499,"id":155641301,"diff_hunk":"@@ -908,6 +1015,204 @@ func (sb *syncBuffer) rotateFile(now time.Time) error {\n \treturn err\n }\n \n+// converts plain log file to gzipped log file. New file is created\n+func gzipFile(name string) error {\n+\tgzipped, err := os.Create(name + \".gz\")\n+\tdefer gzipped.Close()\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\twriter := bufio.NewWriter(gzipped)\n+\tgzipWriter := gzip.NewWriter(writer)\n+\n+\tplain, err := os.Open(name)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\treader := bufio.NewReader(plain)\n+\n+\t// copy from plain text file to gzipped output\n+\t_, err = io.Copy(gzipWriter, reader)\n+\t_ = plain.Close()\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tif err = gzipWriter.Close(); err != nil {\n+\t\treturn err\n+\t}\n+\tif err = writer.Flush(); err != nil {\n+\t\treturn err\n+\t}\n+\tif err = gzipped.Close(); err != nil {\n+\t\treturn err\n+\t}\n+\n+\treturn os.Remove(name)\n+}\n+\n+func (sb *syncBuffer) rotateOld(now time.Time) {\n+\tlogs, err := getLogFiles()\n+\tif err != nil {\n+\t\tsb.logger.exit(err)\n+\t}\n+\n+\tlogs = excludeActive(logs)\n+\n+\tlogs, err = removeOutdated(logs, now)\n+\tif err != nil {\n+\t\tsb.logger.exit(err)\n+\t}\n+\n+\tlogs, err = compressOrphans(logs)\n+\tif err != nil {\n+\t\tsb.logger.exit(err)\n+\t}\n+\n+\ttotalSize := getTotalSize(logs)\n+\tfor i := 0; i < len(logs) && totalSize > MaxTotalSize-MaxSize; i++ {\n+\t\terr := os.Remove(filepath.Join(logs[i].dir, logs[i].name))\n+\t\tif err != nil {\n+\t\t\tsb.logger.exit(err)\n+\t\t}\n+\t\ttotalSize -= logs[i].size\n+\t}\n+}\n+\n+type logFile struct {\n+\tdir       string\n+\tname      string\n+\tsize      uint64\n+\ttimestamp string\n+}\n+\n+// getLogFiles returns log files, ordered from oldest to newest\n+func getLogFiles() (logFiles []logFile, err error) {\n+\tpreffix := fmt.Sprintf(\"%s.%s.%s.log.\", program, host, userName)\n+\tfor _, logDir := range logDirs {\n+\t\tfiles, err := ioutil.ReadDir(logDir)\n+\t\tif err == nil {\n+\t\t\tfiles = filterLogFiles(files, preffix)\n+\t\t\tfor _, file := range files {\n+\t\t\t\tlogFiles = append(logFiles, logFile{\n+\t\t\t\t\tdir:       logDir,\n+\t\t\t\t\tname:      file.Name(),\n+\t\t\t\t\tsize:      uint64(file.Size()),\n+\t\t\t\t\ttimestamp: extractTimestamp(file.Name(), preffix),\n+\t\t\t\t})\n+\t\t\t}\n+\t\t\tsort.Slice(logFiles, func(i, j int) bool {\n+\t\t\t\treturn logFiles[i].timestamp < logFiles[j].timestamp\n+\t\t\t})\n+\t\t\treturn logFiles, nil\n+\t\t}","path":"logger/glog/glog.go","position":282,"original_position":282,"commit_id":"15831d9cb60aefd818dfbfb70cc995ba030f7e7c","original_commit_id":"15831d9cb60aefd818dfbfb70cc995ba030f7e7c","user":{"login":"tzdybal","id":1138893,"avatar_url":"https://avatars2.githubusercontent.com/u/1138893?v=4","gravatar_id":"","url":"https://api.github.com/users/tzdybal","html_url":"https://github.com/tzdybal","followers_url":"https://api.github.com/users/tzdybal/followers","following_url":"https://api.github.com/users/tzdybal/following{/other_user}","gists_url":"https://api.github.com/users/tzdybal/gists{/gist_id}","starred_url":"https://api.github.com/users/tzdybal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzdybal/subscriptions","organizations_url":"https://api.github.com/users/tzdybal/orgs","repos_url":"https://api.github.com/users/tzdybal/repos","events_url":"https://api.github.com/users/tzdybal/events{/privacy}","received_events_url":"https://api.github.com/users/tzdybal/received_events","type":"User","site_admin":false},"body":"This is a bit tricky loop construct from `glog` itself ;) It searches for first usable logging directory (configured one or temporary directory). To be consistent with rest of `glog`, we're complaining only when no directories work for us.","created_at":"2017-12-07T21:08:15Z","updated_at":"2017-12-07T21:11:40Z","html_url":"https://github.com/ethereumproject/go-ethereum/pull/426#discussion_r155641301","pull_request_url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/comments/155641301"},"html":{"href":"https://github.com/ethereumproject/go-ethereum/pull/426#discussion_r155641301"},"pull_request":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426"}},"in_reply_to_id":155596175},"pull_request":{"url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426","id":157026504,"html_url":"https://github.com/ethereumproject/go-ethereum/pull/426","diff_url":"https://github.com/ethereumproject/go-ethereum/pull/426.diff","patch_url":"https://github.com/ethereumproject/go-ethereum/pull/426.patch","issue_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/426","number":426,"state":"open","locked":false,"title":"New feature: log rotation","user":{"login":"tzdybal","id":1138893,"avatar_url":"https://avatars2.githubusercontent.com/u/1138893?v=4","gravatar_id":"","url":"https://api.github.com/users/tzdybal","html_url":"https://github.com/tzdybal","followers_url":"https://api.github.com/users/tzdybal/followers","following_url":"https://api.github.com/users/tzdybal/following{/other_user}","gists_url":"https://api.github.com/users/tzdybal/gists{/gist_id}","starred_url":"https://api.github.com/users/tzdybal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzdybal/subscriptions","organizations_url":"https://api.github.com/users/tzdybal/orgs","repos_url":"https://api.github.com/users/tzdybal/repos","events_url":"https://api.github.com/users/tzdybal/events{/privacy}","received_events_url":"https://api.github.com/users/tzdybal/received_events","type":"User","site_admin":false},"body":"Changes in `logger/glog` and `cmd/geth` to implement highly configurable log rotation. \r\nThis resolves #421.","created_at":"2017-12-07T15:36:32Z","updated_at":"2017-12-07T21:11:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2b140be84ccebebcbc679bb27223c5fca004fa6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"sudachen","id":1428,"avatar_url":"https://avatars2.githubusercontent.com/u/1428?v=4","gravatar_id":"","url":"https://api.github.com/users/sudachen","html_url":"https://github.com/sudachen","followers_url":"https://api.github.com/users/sudachen/followers","following_url":"https://api.github.com/users/sudachen/following{/other_user}","gists_url":"https://api.github.com/users/sudachen/gists{/gist_id}","starred_url":"https://api.github.com/users/sudachen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudachen/subscriptions","organizations_url":"https://api.github.com/users/sudachen/orgs","repos_url":"https://api.github.com/users/sudachen/repos","events_url":"https://api.github.com/users/sudachen/events{/privacy}","received_events_url":"https://api.github.com/users/sudachen/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426/commits","review_comments_url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426/comments","review_comment_url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/426/comments","statuses_url":"https://api.github.com/repos/ethereumproject/go-ethereum/statuses/15831d9cb60aefd818dfbfb70cc995ba030f7e7c","head":{"label":"ethereumproject:feature/log-rotation","ref":"feature/log-rotation","sha":"15831d9cb60aefd818dfbfb70cc995ba030f7e7c","user":{"login":"ethereumproject","id":20253748,"avatar_url":"https://avatars3.githubusercontent.com/u/20253748?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereumproject","html_url":"https://github.com/ethereumproject","followers_url":"https://api.github.com/users/ethereumproject/followers","following_url":"https://api.github.com/users/ethereumproject/following{/other_user}","gists_url":"https://api.github.com/users/ethereumproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereumproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereumproject/subscriptions","organizations_url":"https://api.github.com/users/ethereumproject/orgs","repos_url":"https://api.github.com/users/ethereumproject/repos","events_url":"https://api.github.com/users/ethereumproject/events{/privacy}","received_events_url":"https://api.github.com/users/ethereumproject/received_events","type":"Organization","site_admin":false},"repo":{"id":63557034,"name":"go-ethereum","full_name":"ethereumproject/go-ethereum","owner":{"login":"ethereumproject","id":20253748,"avatar_url":"https://avatars3.githubusercontent.com/u/20253748?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereumproject","html_url":"https://github.com/ethereumproject","followers_url":"https://api.github.com/users/ethereumproject/followers","following_url":"https://api.github.com/users/ethereumproject/following{/other_user}","gists_url":"https://api.github.com/users/ethereumproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereumproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereumproject/subscriptions","organizations_url":"https://api.github.com/users/ethereumproject/orgs","repos_url":"https://api.github.com/users/ethereumproject/repos","events_url":"https://api.github.com/users/ethereumproject/events{/privacy}","received_events_url":"https://api.github.com/users/ethereumproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereumproject/go-ethereum","description":"Go language implementation of the original/classic design of the Ethereum protocol ","fork":false,"url":"https://api.github.com/repos/ethereumproject/go-ethereum","forks_url":"https://api.github.com/repos/ethereumproject/go-ethereum/forks","keys_url":"https://api.github.com/repos/ethereumproject/go-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereumproject/go-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereumproject/go-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereumproject/go-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereumproject/go-ethereum/events","assignees_url":"https://api.github.com/repos/ethereumproject/go-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereumproject/go-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereumproject/go-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereumproject/go-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereumproject/go-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereumproject/go-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereumproject/go-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereumproject/go-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereumproject/go-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereumproject/go-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereumproject/go-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereumproject/go-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereumproject/go-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereumproject/go-ethereum/merges","archive_url":"https://api.github.com/repos/ethereumproject/go-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereumproject/go-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereumproject/go-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereumproject/go-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereumproject/go-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereumproject/go-ethereum/releases{/id}","deployments_url":"https://api.github.com/repos/ethereumproject/go-ethereum/deployments","created_at":"2016-07-17T23:29:57Z","updated_at":"2017-12-07T04:45:45Z","pushed_at":"2017-12-07T20:23:44Z","git_url":"git://github.com/ethereumproject/go-ethereum.git","ssh_url":"git@github.com:ethereumproject/go-ethereum.git","clone_url":"https://github.com/ethereumproject/go-ethereum.git","svn_url":"https://github.com/ethereumproject/go-ethereum","homepage":"","size":80762,"stargazers_count":179,"watchers_count":179,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":97,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0"},"forks":97,"open_issues":49,"watchers":179,"default_branch":"master"}},"base":{"label":"ethereumproject:master","ref":"master","sha":"b237a45ad0882b8fd854c9b855f4550350a66af5","user":{"login":"ethereumproject","id":20253748,"avatar_url":"https://avatars3.githubusercontent.com/u/20253748?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereumproject","html_url":"https://github.com/ethereumproject","followers_url":"https://api.github.com/users/ethereumproject/followers","following_url":"https://api.github.com/users/ethereumproject/following{/other_user}","gists_url":"https://api.github.com/users/ethereumproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereumproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereumproject/subscriptions","organizations_url":"https://api.github.com/users/ethereumproject/orgs","repos_url":"https://api.github.com/users/ethereumproject/repos","events_url":"https://api.github.com/users/ethereumproject/events{/privacy}","received_events_url":"https://api.github.com/users/ethereumproject/received_events","type":"Organization","site_admin":false},"repo":{"id":63557034,"name":"go-ethereum","full_name":"ethereumproject/go-ethereum","owner":{"login":"ethereumproject","id":20253748,"avatar_url":"https://avatars3.githubusercontent.com/u/20253748?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereumproject","html_url":"https://github.com/ethereumproject","followers_url":"https://api.github.com/users/ethereumproject/followers","following_url":"https://api.github.com/users/ethereumproject/following{/other_user}","gists_url":"https://api.github.com/users/ethereumproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereumproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereumproject/subscriptions","organizations_url":"https://api.github.com/users/ethereumproject/orgs","repos_url":"https://api.github.com/users/ethereumproject/repos","events_url":"https://api.github.com/users/ethereumproject/events{/privacy}","received_events_url":"https://api.github.com/users/ethereumproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereumproject/go-ethereum","description":"Go language implementation of the original/classic design of the Ethereum protocol ","fork":false,"url":"https://api.github.com/repos/ethereumproject/go-ethereum","forks_url":"https://api.github.com/repos/ethereumproject/go-ethereum/forks","keys_url":"https://api.github.com/repos/ethereumproject/go-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereumproject/go-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereumproject/go-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereumproject/go-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereumproject/go-ethereum/events","assignees_url":"https://api.github.com/repos/ethereumproject/go-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereumproject/go-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereumproject/go-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereumproject/go-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereumproject/go-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereumproject/go-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereumproject/go-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereumproject/go-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereumproject/go-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereumproject/go-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereumproject/go-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereumproject/go-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereumproject/go-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereumproject/go-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereumproject/go-ethereum/merges","archive_url":"https://api.github.com/repos/ethereumproject/go-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereumproject/go-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereumproject/go-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereumproject/go-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereumproject/go-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereumproject/go-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereumproject/go-ethereum/releases{/id}","deployments_url":"https://api.github.com/repos/ethereumproject/go-ethereum/deployments","created_at":"2016-07-17T23:29:57Z","updated_at":"2017-12-07T04:45:45Z","pushed_at":"2017-12-07T20:23:44Z","git_url":"git://github.com/ethereumproject/go-ethereum.git","ssh_url":"git@github.com:ethereumproject/go-ethereum.git","clone_url":"https://github.com/ethereumproject/go-ethereum.git","svn_url":"https://github.com/ethereumproject/go-ethereum","homepage":"","size":80762,"stargazers_count":179,"watchers_count":179,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":97,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0"},"forks":97,"open_issues":49,"watchers":179,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426"},"html":{"href":"https://github.com/ethereumproject/go-ethereum/pull/426"},"issue":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/426"},"comments":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/issues/426/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/pulls/426/commits"},"statuses":{"href":"https://api.github.com/repos/ethereumproject/go-ethereum/statuses/15831d9cb60aefd818dfbfb70cc995ba030f7e7c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"tzdybal"}}