{"action":"created","comment":{"url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/comments/207343370","pull_request_review_id":142938430,"id":207343370,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzM0MzM3MA==","diff_hunk":"@@ -0,0 +1,104 @@\n+/**\n+ *  Copyright (c) 2018 Red Hat, Inc.\n+ *  All rights reserved. This program and the accompanying materials\n+ *  are made available under the terms of the Eclipse Public License v1.0\n+ *  which accompanies this distribution, and is available at\n+ *  http://www.eclipse.org/legal/epl-v10.html\n+ *\n+ *  Contributors:\n+ *  Nikolas Komonen <nikolaskomonen@gmail.com>, Red Hat Inc. - initial API and implementation\n+ */\n+\n+package org.eclipse.lsp4xml.utils;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.nio.file.Paths;\n+import java.util.Map;\n+import java.util.logging.FileHandler;\n+import java.util.logging.Handler;\n+import java.util.logging.Level;\n+import java.util.logging.Logger;\n+import java.util.logging.SimpleFormatter;\n+\n+import org.eclipse.lsp4j.services.LanguageClient;\n+\n+/**\n+ * LogHelper\n+ */\n+public class LogHelper {\n+\n+\t// This will apply to all child loggers\n+\tpublic static void initializeRootLogger(LanguageClient newLanguageClient, Map<?, ?> initializationObject) {\n+\t\tif(newLanguageClient == null || initializationObject == null) {\n+\t\t\treturn;\n+\t\t}\n+\t\tLogger logger = Logger.getLogger(\"\");\n+\t\tunregisterAllHandlers(logger.getHandlers());\n+\t\tlogger.setLevel(Level.SEVERE);\n+\t\tlogger.setUseParentHandlers(false);// Stops output to console\n+\n+\t\ttry {\n+\t\t\tlogger.addHandler(LogHelper.getClientHandler(newLanguageClient));\n+\t\t} catch (Exception e) {\n+\t\t\t// TODO: handle exception\n+\t\t}\n+\n+\t\tString path = (String) initializationObject.get(\"lsp4xml.logPath\");\n+\t\tif (path != null) {\n+\t\t\tcreateDirectoryPath(path);\n+\t\t\ttry {\n+\t\t\t\tFileHandler fh = LogHelper.getFileHandler(path);\n+\t\t\t\tif (fh != null) {\n+\t\t\t\t\tlogger.addHandler(fh);\n+\t\t\t\t}\n+\t\t\t} catch (SecurityException | IOException e) {\n+\t\t\t\tlogger.log(Level.WARNING, \"Error at creation of FileHandler for logging\");\n+\t\t\t}\n+\t\t} else {\n+\t\t\tlogger.log(Level.INFO, \"Log file could not be created, path not provided\");\n+\t\t}\n+\n+\t}\n+\n+\tprivate static void createDirectoryPath(String path) {\n+\t\tString parentPath = Paths.get(path).normalize().getParent().toString();\n+\t\tnew File(parentPath).mkdirs();\n+\t}\n+\n+\tpublic static ClientLogHandler getClientHandler(LanguageClient languageClient) {\n+\t\tif(languageClient == null) {\n+\t\t\treturn null;\n+\t\t}\n+\t\treturn new ClientLogHandler(languageClient);\n+\t}\n+\n+\tpublic static FileHandler getFileHandler(String filePath) throws SecurityException, IOException {\n+\t\tif(filePath == null) {\n+\t\t\tthrow new IOException();\n+\t\t}","path":"org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/LogHelper.java","position":79,"original_position":79,"commit_id":"0d50101d93fa96b2c81aef874cf8b7dab87c7fe6","original_commit_id":"0d50101d93fa96b2c81aef874cf8b7dab87c7fe6","user":{"login":"fbricon","id":148698,"node_id":"MDQ6VXNlcjE0ODY5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/148698?v=4","gravatar_id":"","url":"https://api.github.com/users/fbricon","html_url":"https://github.com/fbricon","followers_url":"https://api.github.com/users/fbricon/followers","following_url":"https://api.github.com/users/fbricon/following{/other_user}","gists_url":"https://api.github.com/users/fbricon/gists{/gist_id}","starred_url":"https://api.github.com/users/fbricon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fbricon/subscriptions","organizations_url":"https://api.github.com/users/fbricon/orgs","repos_url":"https://api.github.com/users/fbricon/repos","events_url":"https://api.github.com/users/fbricon/events{/privacy}","received_events_url":"https://api.github.com/users/fbricon/received_events","type":"User","site_admin":false},"body":"check if filePath exists, then it must be a writeable file","created_at":"2018-08-02T19:18:40Z","updated_at":"2018-08-02T19:18:40Z","html_url":"https://github.com/angelozerr/lsp4xml/pull/24#discussion_r207343370","pull_request_url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/comments/207343370"},"html":{"href":"https://github.com/angelozerr/lsp4xml/pull/24#discussion_r207343370"},"pull_request":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24","id":203340189,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMzQwMTg5","html_url":"https://github.com/angelozerr/lsp4xml/pull/24","diff_url":"https://github.com/angelozerr/lsp4xml/pull/24.diff","patch_url":"https://github.com/angelozerr/lsp4xml/pull/24.patch","issue_url":"https://api.github.com/repos/angelozerr/lsp4xml/issues/24","number":24,"state":"open","locked":false,"title":"Java Logger","user":{"login":"NikolasKomonen","id":32624665,"node_id":"MDQ6VXNlcjMyNjI0NjY1","avatar_url":"https://avatars1.githubusercontent.com/u/32624665?v=4","gravatar_id":"","url":"https://api.github.com/users/NikolasKomonen","html_url":"https://github.com/NikolasKomonen","followers_url":"https://api.github.com/users/NikolasKomonen/followers","following_url":"https://api.github.com/users/NikolasKomonen/following{/other_user}","gists_url":"https://api.github.com/users/NikolasKomonen/gists{/gist_id}","starred_url":"https://api.github.com/users/NikolasKomonen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikolasKomonen/subscriptions","organizations_url":"https://api.github.com/users/NikolasKomonen/orgs","repos_url":"https://api.github.com/users/NikolasKomonen/repos","events_url":"https://api.github.com/users/NikolasKomonen/events{/privacy}","received_events_url":"https://api.github.com/users/NikolasKomonen/received_events","type":"User","site_admin":false},"body":"As of now the logger will log any Exceptions caught in the org.eclipse.lsp4xml package.","created_at":"2018-07-23T20:52:24Z","updated_at":"2018-08-02T19:18:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"525520c575e6b104bf4dddc66cc5f586e0cb1da3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24/commits","review_comments_url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24/comments","review_comment_url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angelozerr/lsp4xml/issues/24/comments","statuses_url":"https://api.github.com/repos/angelozerr/lsp4xml/statuses/0d50101d93fa96b2c81aef874cf8b7dab87c7fe6","head":{"label":"NikolasKomonen:loggerFinal","ref":"loggerFinal","sha":"0d50101d93fa96b2c81aef874cf8b7dab87c7fe6","user":{"login":"NikolasKomonen","id":32624665,"node_id":"MDQ6VXNlcjMyNjI0NjY1","avatar_url":"https://avatars1.githubusercontent.com/u/32624665?v=4","gravatar_id":"","url":"https://api.github.com/users/NikolasKomonen","html_url":"https://github.com/NikolasKomonen","followers_url":"https://api.github.com/users/NikolasKomonen/followers","following_url":"https://api.github.com/users/NikolasKomonen/following{/other_user}","gists_url":"https://api.github.com/users/NikolasKomonen/gists{/gist_id}","starred_url":"https://api.github.com/users/NikolasKomonen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikolasKomonen/subscriptions","organizations_url":"https://api.github.com/users/NikolasKomonen/orgs","repos_url":"https://api.github.com/users/NikolasKomonen/repos","events_url":"https://api.github.com/users/NikolasKomonen/events{/privacy}","received_events_url":"https://api.github.com/users/NikolasKomonen/received_events","type":"User","site_admin":false},"repo":{"id":138757816,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg3NTc4MTY=","name":"xml-languageserver","full_name":"NikolasKomonen/xml-languageserver","owner":{"login":"NikolasKomonen","id":32624665,"node_id":"MDQ6VXNlcjMyNjI0NjY1","avatar_url":"https://avatars1.githubusercontent.com/u/32624665?v=4","gravatar_id":"","url":"https://api.github.com/users/NikolasKomonen","html_url":"https://github.com/NikolasKomonen","followers_url":"https://api.github.com/users/NikolasKomonen/followers","following_url":"https://api.github.com/users/NikolasKomonen/following{/other_user}","gists_url":"https://api.github.com/users/NikolasKomonen/gists{/gist_id}","starred_url":"https://api.github.com/users/NikolasKomonen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikolasKomonen/subscriptions","organizations_url":"https://api.github.com/users/NikolasKomonen/orgs","repos_url":"https://api.github.com/users/NikolasKomonen/repos","events_url":"https://api.github.com/users/NikolasKomonen/events{/privacy}","received_events_url":"https://api.github.com/users/NikolasKomonen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NikolasKomonen/xml-languageserver","description":"XML Language Server","fork":true,"url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver","forks_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/forks","keys_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/teams","hooks_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/hooks","issue_events_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/issues/events{/number}","events_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/events","assignees_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/assignees{/user}","branches_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/branches{/branch}","tags_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/tags","blobs_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/statuses/{sha}","languages_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/languages","stargazers_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/stargazers","contributors_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/contributors","subscribers_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/subscribers","subscription_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/subscription","commits_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/contents/{+path}","compare_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/merges","archive_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/downloads","issues_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/issues{/number}","pulls_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/pulls{/number}","milestones_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/milestones{/number}","notifications_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/labels{/name}","releases_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/releases{/id}","deployments_url":"https://api.github.com/repos/NikolasKomonen/xml-languageserver/deployments","created_at":"2018-06-26T15:29:29Z","updated_at":"2018-07-03T19:01:06Z","pushed_at":"2018-08-02T18:36:19Z","git_url":"git://github.com/NikolasKomonen/xml-languageserver.git","ssh_url":"git@github.com:NikolasKomonen/xml-languageserver.git","clone_url":"https://github.com/NikolasKomonen/xml-languageserver.git","svn_url":"https://github.com/NikolasKomonen/xml-languageserver","homepage":null,"size":1937,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0","node_id":"MDc6TGljZW5zZTMy"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"angelozerr:master","ref":"master","sha":"e1832aa6b562cc3eca3e94d0d44bdbe4d2b2cc1b","user":{"login":"angelozerr","id":1932211,"node_id":"MDQ6VXNlcjE5MzIyMTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1932211?v=4","gravatar_id":"","url":"https://api.github.com/users/angelozerr","html_url":"https://github.com/angelozerr","followers_url":"https://api.github.com/users/angelozerr/followers","following_url":"https://api.github.com/users/angelozerr/following{/other_user}","gists_url":"https://api.github.com/users/angelozerr/gists{/gist_id}","starred_url":"https://api.github.com/users/angelozerr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angelozerr/subscriptions","organizations_url":"https://api.github.com/users/angelozerr/orgs","repos_url":"https://api.github.com/users/angelozerr/repos","events_url":"https://api.github.com/users/angelozerr/events{/privacy}","received_events_url":"https://api.github.com/users/angelozerr/received_events","type":"User","site_admin":false},"repo":{"id":138315669,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgzMTU2Njk=","name":"lsp4xml","full_name":"angelozerr/lsp4xml","owner":{"login":"angelozerr","id":1932211,"node_id":"MDQ6VXNlcjE5MzIyMTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1932211?v=4","gravatar_id":"","url":"https://api.github.com/users/angelozerr","html_url":"https://github.com/angelozerr","followers_url":"https://api.github.com/users/angelozerr/followers","following_url":"https://api.github.com/users/angelozerr/following{/other_user}","gists_url":"https://api.github.com/users/angelozerr/gists{/gist_id}","starred_url":"https://api.github.com/users/angelozerr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angelozerr/subscriptions","organizations_url":"https://api.github.com/users/angelozerr/orgs","repos_url":"https://api.github.com/users/angelozerr/repos","events_url":"https://api.github.com/users/angelozerr/events{/privacy}","received_events_url":"https://api.github.com/users/angelozerr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/angelozerr/lsp4xml","description":"XML Language Server","fork":false,"url":"https://api.github.com/repos/angelozerr/lsp4xml","forks_url":"https://api.github.com/repos/angelozerr/lsp4xml/forks","keys_url":"https://api.github.com/repos/angelozerr/lsp4xml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angelozerr/lsp4xml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angelozerr/lsp4xml/teams","hooks_url":"https://api.github.com/repos/angelozerr/lsp4xml/hooks","issue_events_url":"https://api.github.com/repos/angelozerr/lsp4xml/issues/events{/number}","events_url":"https://api.github.com/repos/angelozerr/lsp4xml/events","assignees_url":"https://api.github.com/repos/angelozerr/lsp4xml/assignees{/user}","branches_url":"https://api.github.com/repos/angelozerr/lsp4xml/branches{/branch}","tags_url":"https://api.github.com/repos/angelozerr/lsp4xml/tags","blobs_url":"https://api.github.com/repos/angelozerr/lsp4xml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angelozerr/lsp4xml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angelozerr/lsp4xml/git/refs{/sha}","trees_url":"https://api.github.com/repos/angelozerr/lsp4xml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angelozerr/lsp4xml/statuses/{sha}","languages_url":"https://api.github.com/repos/angelozerr/lsp4xml/languages","stargazers_url":"https://api.github.com/repos/angelozerr/lsp4xml/stargazers","contributors_url":"https://api.github.com/repos/angelozerr/lsp4xml/contributors","subscribers_url":"https://api.github.com/repos/angelozerr/lsp4xml/subscribers","subscription_url":"https://api.github.com/repos/angelozerr/lsp4xml/subscription","commits_url":"https://api.github.com/repos/angelozerr/lsp4xml/commits{/sha}","git_commits_url":"https://api.github.com/repos/angelozerr/lsp4xml/git/commits{/sha}","comments_url":"https://api.github.com/repos/angelozerr/lsp4xml/comments{/number}","issue_comment_url":"https://api.github.com/repos/angelozerr/lsp4xml/issues/comments{/number}","contents_url":"https://api.github.com/repos/angelozerr/lsp4xml/contents/{+path}","compare_url":"https://api.github.com/repos/angelozerr/lsp4xml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angelozerr/lsp4xml/merges","archive_url":"https://api.github.com/repos/angelozerr/lsp4xml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angelozerr/lsp4xml/downloads","issues_url":"https://api.github.com/repos/angelozerr/lsp4xml/issues{/number}","pulls_url":"https://api.github.com/repos/angelozerr/lsp4xml/pulls{/number}","milestones_url":"https://api.github.com/repos/angelozerr/lsp4xml/milestones{/number}","notifications_url":"https://api.github.com/repos/angelozerr/lsp4xml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angelozerr/lsp4xml/labels{/name}","releases_url":"https://api.github.com/repos/angelozerr/lsp4xml/releases{/id}","deployments_url":"https://api.github.com/repos/angelozerr/lsp4xml/deployments","created_at":"2018-06-22T15:00:18Z","updated_at":"2018-07-30T13:23:49Z","pushed_at":"2018-08-02T18:36:22Z","git_url":"git://github.com/angelozerr/lsp4xml.git","ssh_url":"git@github.com:angelozerr/lsp4xml.git","clone_url":"https://github.com/angelozerr/lsp4xml.git","svn_url":"https://github.com/angelozerr/lsp4xml","homepage":null,"size":1846,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0","node_id":"MDc6TGljZW5zZTMy"},"forks":2,"open_issues":15,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24"},"html":{"href":"https://github.com/angelozerr/lsp4xml/pull/24"},"issue":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/issues/24"},"comments":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/angelozerr/lsp4xml/statuses/0d50101d93fa96b2c81aef874cf8b7dab87c7fe6"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"fbricon"}}