{"action":"created","comment":{"url":"https://api.github.com/repos/rancherio/docker/pulls/comments/26641833","id":26641833,"diff_hunk":"@@ -0,0 +1,144 @@\n+package rollover\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"os\"\n+\t\"strconv\"\n+\n+\t\"github.com/docker/docker/daemon/logger\"\n+\t\"github.com/docker/docker/pkg/jsonlog\"\n+)\n+\n+// RolloverLogger is Logger implementation for rollover docker logging:\n+// JSON objects to file\n+type RolloverLogger struct {\n+\tbuf      *bytes.Buffer\n+\tf        *os.File // store for closing\n+\tcapacity int64\n+\tn        int\n+}\n+\n+func New(filename string, capacity string, n int) (logger.Logger, error) {\n+\tvar capVal int64\n+\tif capacity != \"\" {\n+\t\tvar multiplier int64\n+\t\tcapString := capacity[:len(capacity)-1]\n+\t\tswitch capacity[len(capacity)-1:] {\n+\t\tcase \"K\":\n+\t\t\tmultiplier = 1024\n+\t\tcase \"k\":\n+\t\t\tmultiplier = 1024\n+\t\tcase \"M\":\n+\t\t\tmultiplier = 1024 * 1024\n+\t\tcase \"m\":\n+\t\t\tmultiplier = 1024 * 1024\n+\t\tcase \"G\":\n+\t\t\tmultiplier = 1024 * 1024 * 1024\n+\t\tcase \"g\":\n+\t\t\tmultiplier = 1024 * 1024 * 1024\n+\t\tdefault:\n+\t\t\tmultiplier = 1\n+\t\t\tcapString = capacity\n+\t\t}\n+\t\tcapVal, err := strconv.ParseInt(capString, 10, 64)\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t\tcapVal *= multiplier\n+\t} else {\n+\t\tcapVal = -1\n+\t}\n+\tlog, err := os.OpenFile(filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0600)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn &RolloverLogger{\n+\t\tf:        log,\n+\t\tbuf:      bytes.NewBuffer(nil),\n+\t\tcapacity: capVal,\n+\t\tn:        n,\n+\t}, nil\n+}\n+\n+// Log converts logger.Message to jsonlog.JSONLog and serializes it to file\n+func (l *RolloverLogger) Log(msg *logger.Message) error {\n+\tif err := (&jsonlog.JSONLog{Log: string(msg.Line) + \"\\n\", Stream: msg.Source, Created: msg.Timestamp}).MarshalJSONBuf(l.buf); err != nil {\n+\t\treturn err\n+\t}\n+\tl.buf.WriteByte('\\n')\n+\t_, err := writeLog(l)\n+\treturn err\n+}\n+\n+func writeLog(l *RolloverLogger) (int64, error) {\n+\tif l.capacity == -1 {\n+\t\treturn l.buf.WriteTo(l.f)\n+\t}\n+\tmeta, err := l.f.Stat()","path":"daemon/logger/rollover/rollover.go","position":78,"original_position":78,"commit_id":"9955d53fdb24c159481b29b547ad91952c159511","original_commit_id":"9955d53fdb24c159481b29b547ad91952c159511","user":{"login":"ibuildthecloud","id":1754002,"avatar_url":"https://avatars.githubusercontent.com/u/1754002?v=3","gravatar_id":"","url":"https://api.github.com/users/ibuildthecloud","html_url":"https://github.com/ibuildthecloud","followers_url":"https://api.github.com/users/ibuildthecloud/followers","following_url":"https://api.github.com/users/ibuildthecloud/following{/other_user}","gists_url":"https://api.github.com/users/ibuildthecloud/gists{/gist_id}","starred_url":"https://api.github.com/users/ibuildthecloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibuildthecloud/subscriptions","organizations_url":"https://api.github.com/users/ibuildthecloud/orgs","repos_url":"https://api.github.com/users/ibuildthecloud/repos","events_url":"https://api.github.com/users/ibuildthecloud/events{/privacy}","received_events_url":"https://api.github.com/users/ibuildthecloud/received_events","type":"User","site_admin":false},"body":"I'd be concerned about the number of stats you would have to do.  Not sure if this is going to be a problem.","created_at":"2015-03-18T07:01:36Z","updated_at":"2015-03-18T07:01:36Z","html_url":"https://github.com/rancherio/docker/pull/2#discussion_r26641833","pull_request_url":"https://api.github.com/repos/rancherio/docker/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/rancherio/docker/pulls/comments/26641833"},"html":{"href":"https://github.com/rancherio/docker/pull/2#discussion_r26641833"},"pull_request":{"href":"https://api.github.com/repos/rancherio/docker/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/rancherio/docker/pulls/2","id":30787951,"html_url":"https://github.com/rancherio/docker/pull/2","diff_url":"https://github.com/rancherio/docker/pull/2.diff","patch_url":"https://github.com/rancherio/docker/pull/2.patch","issue_url":"https://api.github.com/repos/rancherio/docker/issues/2","number":2,"state":"open","locked":false,"title":"Logging impl","user":{"login":"wlan0","id":1050521,"avatar_url":"https://avatars.githubusercontent.com/u/1050521?v=3","gravatar_id":"","url":"https://api.github.com/users/wlan0","html_url":"https://github.com/wlan0","followers_url":"https://api.github.com/users/wlan0/followers","following_url":"https://api.github.com/users/wlan0/following{/other_user}","gists_url":"https://api.github.com/users/wlan0/gists{/gist_id}","starred_url":"https://api.github.com/users/wlan0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlan0/subscriptions","organizations_url":"https://api.github.com/users/wlan0/orgs","repos_url":"https://api.github.com/users/wlan0/repos","events_url":"https://api.github.com/users/wlan0/events{/privacy}","received_events_url":"https://api.github.com/users/wlan0/received_events","type":"User","site_admin":false},"body":"@ibuildthecloud ","created_at":"2015-03-09T18:42:22Z","updated_at":"2015-03-18T07:01:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bde667f9c03f5ead6d926c5cf0617dfdab9558a9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rancherio/docker/pulls/2/commits","review_comments_url":"https://api.github.com/repos/rancherio/docker/pulls/2/comments","review_comment_url":"https://api.github.com/repos/rancherio/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rancherio/docker/issues/2/comments","statuses_url":"https://api.github.com/repos/rancherio/docker/statuses/9955d53fdb24c159481b29b547ad91952c159511","head":{"label":"wlan0:logging_impl","ref":"logging_impl","sha":"9955d53fdb24c159481b29b547ad91952c159511","user":{"login":"wlan0","id":1050521,"avatar_url":"https://avatars.githubusercontent.com/u/1050521?v=3","gravatar_id":"","url":"https://api.github.com/users/wlan0","html_url":"https://github.com/wlan0","followers_url":"https://api.github.com/users/wlan0/followers","following_url":"https://api.github.com/users/wlan0/following{/other_user}","gists_url":"https://api.github.com/users/wlan0/gists{/gist_id}","starred_url":"https://api.github.com/users/wlan0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlan0/subscriptions","organizations_url":"https://api.github.com/users/wlan0/orgs","repos_url":"https://api.github.com/users/wlan0/repos","events_url":"https://api.github.com/users/wlan0/events{/privacy}","received_events_url":"https://api.github.com/users/wlan0/received_events","type":"User","site_admin":false},"repo":{"id":31682821,"name":"docker","full_name":"wlan0/docker","owner":{"login":"wlan0","id":1050521,"avatar_url":"https://avatars.githubusercontent.com/u/1050521?v=3","gravatar_id":"","url":"https://api.github.com/users/wlan0","html_url":"https://github.com/wlan0","followers_url":"https://api.github.com/users/wlan0/followers","following_url":"https://api.github.com/users/wlan0/following{/other_user}","gists_url":"https://api.github.com/users/wlan0/gists{/gist_id}","starred_url":"https://api.github.com/users/wlan0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlan0/subscriptions","organizations_url":"https://api.github.com/users/wlan0/orgs","repos_url":"https://api.github.com/users/wlan0/repos","events_url":"https://api.github.com/users/wlan0/events{/privacy}","received_events_url":"https://api.github.com/users/wlan0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wlan0/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/wlan0/docker","forks_url":"https://api.github.com/repos/wlan0/docker/forks","keys_url":"https://api.github.com/repos/wlan0/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wlan0/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wlan0/docker/teams","hooks_url":"https://api.github.com/repos/wlan0/docker/hooks","issue_events_url":"https://api.github.com/repos/wlan0/docker/issues/events{/number}","events_url":"https://api.github.com/repos/wlan0/docker/events","assignees_url":"https://api.github.com/repos/wlan0/docker/assignees{/user}","branches_url":"https://api.github.com/repos/wlan0/docker/branches{/branch}","tags_url":"https://api.github.com/repos/wlan0/docker/tags","blobs_url":"https://api.github.com/repos/wlan0/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wlan0/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wlan0/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/wlan0/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wlan0/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/wlan0/docker/languages","stargazers_url":"https://api.github.com/repos/wlan0/docker/stargazers","contributors_url":"https://api.github.com/repos/wlan0/docker/contributors","subscribers_url":"https://api.github.com/repos/wlan0/docker/subscribers","subscription_url":"https://api.github.com/repos/wlan0/docker/subscription","commits_url":"https://api.github.com/repos/wlan0/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/wlan0/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/wlan0/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/wlan0/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/wlan0/docker/contents/{+path}","compare_url":"https://api.github.com/repos/wlan0/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wlan0/docker/merges","archive_url":"https://api.github.com/repos/wlan0/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wlan0/docker/downloads","issues_url":"https://api.github.com/repos/wlan0/docker/issues{/number}","pulls_url":"https://api.github.com/repos/wlan0/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/wlan0/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/wlan0/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wlan0/docker/labels{/name}","releases_url":"https://api.github.com/repos/wlan0/docker/releases{/id}","created_at":"2015-03-04T22:15:59Z","updated_at":"2015-03-04T22:38:02Z","pushed_at":"2015-03-18T04:59:29Z","git_url":"git://github.com/wlan0/docker.git","ssh_url":"git@github.com:wlan0/docker.git","clone_url":"https://github.com/wlan0/docker.git","svn_url":"https://github.com/wlan0/docker","homepage":"http://www.docker.com","size":45386,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rancherio:master","ref":"master","sha":"a5269223a78d963774b12359a1e505b10fa9ac81","user":{"login":"rancherio","id":9343010,"avatar_url":"https://avatars.githubusercontent.com/u/9343010?v=3","gravatar_id":"","url":"https://api.github.com/users/rancherio","html_url":"https://github.com/rancherio","followers_url":"https://api.github.com/users/rancherio/followers","following_url":"https://api.github.com/users/rancherio/following{/other_user}","gists_url":"https://api.github.com/users/rancherio/gists{/gist_id}","starred_url":"https://api.github.com/users/rancherio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancherio/subscriptions","organizations_url":"https://api.github.com/users/rancherio/orgs","repos_url":"https://api.github.com/users/rancherio/repos","events_url":"https://api.github.com/users/rancherio/events{/privacy}","received_events_url":"https://api.github.com/users/rancherio/received_events","type":"Organization","site_admin":false},"repo":{"id":31273720,"name":"docker","full_name":"rancherio/docker","owner":{"login":"rancherio","id":9343010,"avatar_url":"https://avatars.githubusercontent.com/u/9343010?v=3","gravatar_id":"","url":"https://api.github.com/users/rancherio","html_url":"https://github.com/rancherio","followers_url":"https://api.github.com/users/rancherio/followers","following_url":"https://api.github.com/users/rancherio/following{/other_user}","gists_url":"https://api.github.com/users/rancherio/gists{/gist_id}","starred_url":"https://api.github.com/users/rancherio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancherio/subscriptions","organizations_url":"https://api.github.com/users/rancherio/orgs","repos_url":"https://api.github.com/users/rancherio/repos","events_url":"https://api.github.com/users/rancherio/events{/privacy}","received_events_url":"https://api.github.com/users/rancherio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rancherio/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/rancherio/docker","forks_url":"https://api.github.com/repos/rancherio/docker/forks","keys_url":"https://api.github.com/repos/rancherio/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rancherio/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rancherio/docker/teams","hooks_url":"https://api.github.com/repos/rancherio/docker/hooks","issue_events_url":"https://api.github.com/repos/rancherio/docker/issues/events{/number}","events_url":"https://api.github.com/repos/rancherio/docker/events","assignees_url":"https://api.github.com/repos/rancherio/docker/assignees{/user}","branches_url":"https://api.github.com/repos/rancherio/docker/branches{/branch}","tags_url":"https://api.github.com/repos/rancherio/docker/tags","blobs_url":"https://api.github.com/repos/rancherio/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rancherio/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rancherio/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/rancherio/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rancherio/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/rancherio/docker/languages","stargazers_url":"https://api.github.com/repos/rancherio/docker/stargazers","contributors_url":"https://api.github.com/repos/rancherio/docker/contributors","subscribers_url":"https://api.github.com/repos/rancherio/docker/subscribers","subscription_url":"https://api.github.com/repos/rancherio/docker/subscription","commits_url":"https://api.github.com/repos/rancherio/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/rancherio/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/rancherio/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/rancherio/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/rancherio/docker/contents/{+path}","compare_url":"https://api.github.com/repos/rancherio/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rancherio/docker/merges","archive_url":"https://api.github.com/repos/rancherio/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rancherio/docker/downloads","issues_url":"https://api.github.com/repos/rancherio/docker/issues{/number}","pulls_url":"https://api.github.com/repos/rancherio/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/rancherio/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/rancherio/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rancherio/docker/labels{/name}","releases_url":"https://api.github.com/repos/rancherio/docker/releases{/id}","created_at":"2015-02-24T18:01:04Z","updated_at":"2015-03-18T02:20:48Z","pushed_at":"2015-03-18T02:20:46Z","git_url":"git://github.com/rancherio/docker.git","ssh_url":"git@github.com:rancherio/docker.git","clone_url":"https://github.com/rancherio/docker.git","svn_url":"https://github.com/rancherio/docker","homepage":"http://www.docker.com","size":45765,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rancherio/docker/pulls/2"},"html":{"href":"https://github.com/rancherio/docker/pull/2"},"issue":{"href":"https://api.github.com/repos/rancherio/docker/issues/2"},"comments":{"href":"https://api.github.com/repos/rancherio/docker/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/rancherio/docker/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/rancherio/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rancherio/docker/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/rancherio/docker/statuses/9955d53fdb24c159481b29b547ad91952c159511"}}}}