{"action":"created","comment":{"url":"https://api.github.com/repos/scalingdata/log4go/pulls/comments/39324353","id":39324353,"diff_hunk":"@@ -136,28 +163,42 @@ func (w *FileLogWriter) Rotate() {\n \tw.rot <- true\n }\n \n+// Generate the next filename for rotation\n+func (w *FileLogWriter) nextFilename(filename string, suffix string) (string, error) {\n+        // Attempt filename.suffix\n+\tfullName := fmt.Sprintf(\"%s.%s\", filename, suffix)\n+\tif _, err := os.Stat(fullName); os.IsNotExist(err) {\n+\t\t// File does not exist, return it as the next filename\n+\t\treturn fullName, nil\n+\t}\n+\n+\t// If necessary, add integer suffix\n+\tfor i := 1; i < 10000; i++ {\n+\t\tfullNameWithSuffix := fmt.Sprintf(\"%s.%s.%04d\", filename, suffix, i)\n+\t\tif _, err := os.Stat(fullNameWithSuffix); os.IsNotExist(err) {","path":"filelog.go","position":96,"original_position":96,"commit_id":"ff255e36b2e5240b3a1652ba644d9f4509d4cd93","original_commit_id":"ff255e36b2e5240b3a1652ba644d9f4509d4cd93","user":{"login":"MarkRoddy","id":346362,"avatar_url":"https://avatars.githubusercontent.com/u/346362?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkRoddy","html_url":"https://github.com/MarkRoddy","followers_url":"https://api.github.com/users/MarkRoddy/followers","following_url":"https://api.github.com/users/MarkRoddy/following{/other_user}","gists_url":"https://api.github.com/users/MarkRoddy/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkRoddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkRoddy/subscriptions","organizations_url":"https://api.github.com/users/MarkRoddy/orgs","repos_url":"https://api.github.com/users/MarkRoddy/repos","events_url":"https://api.github.com/users/MarkRoddy/events{/privacy}","received_events_url":"https://api.github.com/users/MarkRoddy/received_events","type":"User","site_admin":false},"body":"What if there's an error stat'ing the directory?  We might want to check for that condition, otherwise the output is going to be `Unable to obtain next logfile increment for %s.%s\\n\", filename, suffix` which isn't very helpful from the user's perspective.","created_at":"2015-09-11T22:22:47Z","updated_at":"2015-09-11T22:22:47Z","html_url":"https://github.com/scalingdata/log4go/pull/8#discussion_r39324353","pull_request_url":"https://api.github.com/repos/scalingdata/log4go/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/scalingdata/log4go/pulls/comments/39324353"},"html":{"href":"https://github.com/scalingdata/log4go/pull/8#discussion_r39324353"},"pull_request":{"href":"https://api.github.com/repos/scalingdata/log4go/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/scalingdata/log4go/pulls/8","id":44796849,"html_url":"https://github.com/scalingdata/log4go/pull/8","diff_url":"https://github.com/scalingdata/log4go/pull/8.diff","patch_url":"https://github.com/scalingdata/log4go/pull/8.patch","issue_url":"https://api.github.com/repos/scalingdata/log4go/issues/8","number":8,"state":"open","locked":false,"title":"ROCANA-1481: Log rotation naming different from other log files","user":{"login":"adam-rocana","id":13948507,"avatar_url":"https://avatars.githubusercontent.com/u/13948507?v=3","gravatar_id":"","url":"https://api.github.com/users/adam-rocana","html_url":"https://github.com/adam-rocana","followers_url":"https://api.github.com/users/adam-rocana/followers","following_url":"https://api.github.com/users/adam-rocana/following{/other_user}","gists_url":"https://api.github.com/users/adam-rocana/gists{/gist_id}","starred_url":"https://api.github.com/users/adam-rocana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adam-rocana/subscriptions","organizations_url":"https://api.github.com/users/adam-rocana/orgs","repos_url":"https://api.github.com/users/adam-rocana/repos","events_url":"https://api.github.com/users/adam-rocana/events{/privacy}","received_events_url":"https://api.github.com/users/adam-rocana/received_events","type":"User","site_admin":false},"body":"This commit uses a date suffix for log files and rotates the current log file when the date changes. Features like rotation on max lines and file size are preserved.","created_at":"2015-09-11T15:39:06Z","updated_at":"2015-09-11T22:22:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa33a4e7ac2d6117bd23d910e9384d39257c9b58","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scalingdata/log4go/pulls/8/commits","review_comments_url":"https://api.github.com/repos/scalingdata/log4go/pulls/8/comments","review_comment_url":"https://api.github.com/repos/scalingdata/log4go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scalingdata/log4go/issues/8/comments","statuses_url":"https://api.github.com/repos/scalingdata/log4go/statuses/ff255e36b2e5240b3a1652ba644d9f4509d4cd93","head":{"label":"scalingdata:ROCANA-1481","ref":"ROCANA-1481","sha":"ff255e36b2e5240b3a1652ba644d9f4509d4cd93","user":{"login":"scalingdata","id":6448302,"avatar_url":"https://avatars.githubusercontent.com/u/6448302?v=3","gravatar_id":"","url":"https://api.github.com/users/scalingdata","html_url":"https://github.com/scalingdata","followers_url":"https://api.github.com/users/scalingdata/followers","following_url":"https://api.github.com/users/scalingdata/following{/other_user}","gists_url":"https://api.github.com/users/scalingdata/gists{/gist_id}","starred_url":"https://api.github.com/users/scalingdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalingdata/subscriptions","organizations_url":"https://api.github.com/users/scalingdata/orgs","repos_url":"https://api.github.com/users/scalingdata/repos","events_url":"https://api.github.com/users/scalingdata/events{/privacy}","received_events_url":"https://api.github.com/users/scalingdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22391062,"name":"log4go","full_name":"scalingdata/log4go","owner":{"login":"scalingdata","id":6448302,"avatar_url":"https://avatars.githubusercontent.com/u/6448302?v=3","gravatar_id":"","url":"https://api.github.com/users/scalingdata","html_url":"https://github.com/scalingdata","followers_url":"https://api.github.com/users/scalingdata/followers","following_url":"https://api.github.com/users/scalingdata/following{/other_user}","gists_url":"https://api.github.com/users/scalingdata/gists{/gist_id}","starred_url":"https://api.github.com/users/scalingdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalingdata/subscriptions","organizations_url":"https://api.github.com/users/scalingdata/orgs","repos_url":"https://api.github.com/users/scalingdata/repos","events_url":"https://api.github.com/users/scalingdata/events{/privacy}","received_events_url":"https://api.github.com/users/scalingdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scalingdata/log4go","description":"Fork of https://code.google.com/p/log4go","fork":false,"url":"https://api.github.com/repos/scalingdata/log4go","forks_url":"https://api.github.com/repos/scalingdata/log4go/forks","keys_url":"https://api.github.com/repos/scalingdata/log4go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scalingdata/log4go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scalingdata/log4go/teams","hooks_url":"https://api.github.com/repos/scalingdata/log4go/hooks","issue_events_url":"https://api.github.com/repos/scalingdata/log4go/issues/events{/number}","events_url":"https://api.github.com/repos/scalingdata/log4go/events","assignees_url":"https://api.github.com/repos/scalingdata/log4go/assignees{/user}","branches_url":"https://api.github.com/repos/scalingdata/log4go/branches{/branch}","tags_url":"https://api.github.com/repos/scalingdata/log4go/tags","blobs_url":"https://api.github.com/repos/scalingdata/log4go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scalingdata/log4go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scalingdata/log4go/git/refs{/sha}","trees_url":"https://api.github.com/repos/scalingdata/log4go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scalingdata/log4go/statuses/{sha}","languages_url":"https://api.github.com/repos/scalingdata/log4go/languages","stargazers_url":"https://api.github.com/repos/scalingdata/log4go/stargazers","contributors_url":"https://api.github.com/repos/scalingdata/log4go/contributors","subscribers_url":"https://api.github.com/repos/scalingdata/log4go/subscribers","subscription_url":"https://api.github.com/repos/scalingdata/log4go/subscription","commits_url":"https://api.github.com/repos/scalingdata/log4go/commits{/sha}","git_commits_url":"https://api.github.com/repos/scalingdata/log4go/git/commits{/sha}","comments_url":"https://api.github.com/repos/scalingdata/log4go/comments{/number}","issue_comment_url":"https://api.github.com/repos/scalingdata/log4go/issues/comments{/number}","contents_url":"https://api.github.com/repos/scalingdata/log4go/contents/{+path}","compare_url":"https://api.github.com/repos/scalingdata/log4go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scalingdata/log4go/merges","archive_url":"https://api.github.com/repos/scalingdata/log4go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scalingdata/log4go/downloads","issues_url":"https://api.github.com/repos/scalingdata/log4go/issues{/number}","pulls_url":"https://api.github.com/repos/scalingdata/log4go/pulls{/number}","milestones_url":"https://api.github.com/repos/scalingdata/log4go/milestones{/number}","notifications_url":"https://api.github.com/repos/scalingdata/log4go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scalingdata/log4go/labels{/name}","releases_url":"https://api.github.com/repos/scalingdata/log4go/releases{/id}","created_at":"2014-07-29T18:41:47Z","updated_at":"2015-02-26T23:12:10Z","pushed_at":"2015-09-11T16:48:10Z","git_url":"git://github.com/scalingdata/log4go.git","ssh_url":"git@github.com:scalingdata/log4go.git","clone_url":"https://github.com/scalingdata/log4go.git","svn_url":"https://github.com/scalingdata/log4go","homepage":null,"size":287,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"scalingdata:master","ref":"master","sha":"de1dac81df3bdcc828880700703cc90bed9729dc","user":{"login":"scalingdata","id":6448302,"avatar_url":"https://avatars.githubusercontent.com/u/6448302?v=3","gravatar_id":"","url":"https://api.github.com/users/scalingdata","html_url":"https://github.com/scalingdata","followers_url":"https://api.github.com/users/scalingdata/followers","following_url":"https://api.github.com/users/scalingdata/following{/other_user}","gists_url":"https://api.github.com/users/scalingdata/gists{/gist_id}","starred_url":"https://api.github.com/users/scalingdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalingdata/subscriptions","organizations_url":"https://api.github.com/users/scalingdata/orgs","repos_url":"https://api.github.com/users/scalingdata/repos","events_url":"https://api.github.com/users/scalingdata/events{/privacy}","received_events_url":"https://api.github.com/users/scalingdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22391062,"name":"log4go","full_name":"scalingdata/log4go","owner":{"login":"scalingdata","id":6448302,"avatar_url":"https://avatars.githubusercontent.com/u/6448302?v=3","gravatar_id":"","url":"https://api.github.com/users/scalingdata","html_url":"https://github.com/scalingdata","followers_url":"https://api.github.com/users/scalingdata/followers","following_url":"https://api.github.com/users/scalingdata/following{/other_user}","gists_url":"https://api.github.com/users/scalingdata/gists{/gist_id}","starred_url":"https://api.github.com/users/scalingdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalingdata/subscriptions","organizations_url":"https://api.github.com/users/scalingdata/orgs","repos_url":"https://api.github.com/users/scalingdata/repos","events_url":"https://api.github.com/users/scalingdata/events{/privacy}","received_events_url":"https://api.github.com/users/scalingdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scalingdata/log4go","description":"Fork of https://code.google.com/p/log4go","fork":false,"url":"https://api.github.com/repos/scalingdata/log4go","forks_url":"https://api.github.com/repos/scalingdata/log4go/forks","keys_url":"https://api.github.com/repos/scalingdata/log4go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scalingdata/log4go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scalingdata/log4go/teams","hooks_url":"https://api.github.com/repos/scalingdata/log4go/hooks","issue_events_url":"https://api.github.com/repos/scalingdata/log4go/issues/events{/number}","events_url":"https://api.github.com/repos/scalingdata/log4go/events","assignees_url":"https://api.github.com/repos/scalingdata/log4go/assignees{/user}","branches_url":"https://api.github.com/repos/scalingdata/log4go/branches{/branch}","tags_url":"https://api.github.com/repos/scalingdata/log4go/tags","blobs_url":"https://api.github.com/repos/scalingdata/log4go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scalingdata/log4go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scalingdata/log4go/git/refs{/sha}","trees_url":"https://api.github.com/repos/scalingdata/log4go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scalingdata/log4go/statuses/{sha}","languages_url":"https://api.github.com/repos/scalingdata/log4go/languages","stargazers_url":"https://api.github.com/repos/scalingdata/log4go/stargazers","contributors_url":"https://api.github.com/repos/scalingdata/log4go/contributors","subscribers_url":"https://api.github.com/repos/scalingdata/log4go/subscribers","subscription_url":"https://api.github.com/repos/scalingdata/log4go/subscription","commits_url":"https://api.github.com/repos/scalingdata/log4go/commits{/sha}","git_commits_url":"https://api.github.com/repos/scalingdata/log4go/git/commits{/sha}","comments_url":"https://api.github.com/repos/scalingdata/log4go/comments{/number}","issue_comment_url":"https://api.github.com/repos/scalingdata/log4go/issues/comments{/number}","contents_url":"https://api.github.com/repos/scalingdata/log4go/contents/{+path}","compare_url":"https://api.github.com/repos/scalingdata/log4go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scalingdata/log4go/merges","archive_url":"https://api.github.com/repos/scalingdata/log4go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scalingdata/log4go/downloads","issues_url":"https://api.github.com/repos/scalingdata/log4go/issues{/number}","pulls_url":"https://api.github.com/repos/scalingdata/log4go/pulls{/number}","milestones_url":"https://api.github.com/repos/scalingdata/log4go/milestones{/number}","notifications_url":"https://api.github.com/repos/scalingdata/log4go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scalingdata/log4go/labels{/name}","releases_url":"https://api.github.com/repos/scalingdata/log4go/releases{/id}","created_at":"2014-07-29T18:41:47Z","updated_at":"2015-02-26T23:12:10Z","pushed_at":"2015-09-11T16:48:10Z","git_url":"git://github.com/scalingdata/log4go.git","ssh_url":"git@github.com:scalingdata/log4go.git","clone_url":"https://github.com/scalingdata/log4go.git","svn_url":"https://github.com/scalingdata/log4go","homepage":null,"size":287,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"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/scalingdata/log4go/pulls/8"},"html":{"href":"https://github.com/scalingdata/log4go/pull/8"},"issue":{"href":"https://api.github.com/repos/scalingdata/log4go/issues/8"},"comments":{"href":"https://api.github.com/repos/scalingdata/log4go/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/scalingdata/log4go/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/scalingdata/log4go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scalingdata/log4go/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/scalingdata/log4go/statuses/ff255e36b2e5240b3a1652ba644d9f4509d4cd93"}}}}