{"action":"created","comment":{"url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/comments/98025946","pull_request_review_id":18652720,"id":98025946,"diff_hunk":"@@ -8,102 +8,64 @@\n #ifndef LOG_LOC\n  #define LOG_LOC \"/cache/lible.log\"\n #endif\n-\n-\n-int klog(char *msg)\n+/*\n+  This is the main function \"klog\"\n+  it takes the the log level\n+  ==================================== \\\n+   label  | loglevel | message         /\n+  ==================================== \\\n+  | Info  | 0        |  Info :         /\n+  | Warn  | 1        |  Warn :         \\\n+  | Error | 2        |  Error :        /\n+  | Debug | 3        |  Debug :        \\\n+  ==================================== /\n+  then opens the /dev/kmsg or LOG_LOC\n+  if it cant acces the location\n+  it tries to open the LOG_LOC\n+  and print COULD NOT OPEN KMSG PLEASE FIX\n+*/\n+int klog(int level, char *msg)\n {\n \n- char *buf = malloc(256);\n  int ret = -1;\n+ char tag [256];\n \n-  // Write to kmsg if possibe.\n  int outbuf = open(\"/dev/kmsg\", O_WRONLY);\n-  if (outbuf > 0) // Trying to open KMSG,\n+  if (outbuf > 0)\n   {\n-    strcpy(buf,msg);\n-  } else { //If kmesg don't open write to sd\n-    /*\n-      Now if the file doesn't exists, we would open another file on the sdcard to transmit our KMSG.\n-    */\n-    if (access(LOG_LOC, F_OK ) == -1) {  // Check if the file exists.\n-      outbuf = open(LOG_LOC, O_CREAT | O_WRONLY); // If it doesn't exist, create it and open it to write to it.\n+    switch (level)\n+     {\n+      case 0 : tag = \"Info :\" ;\n+                strcat(tag,msg);\n+                break ;\n+\n+      case 1 : tag = \"Warn :\";\n+                strcat(tag,msg);\n+              break ;\n+      case 2 : tag = \"Error :\"\n+                strcat(tag,msg);\n+              break ;\n+      case 3 : tag = \"Debug :\"\n+                strcat(tag,msg);\n+              break ;\n+      default : tag = \"Error : Unknown log level \"\n+                break;\n+    }\n+\n \n+  } else {\n+    if (access(LOG_LOC, F_OK ) == -1) {\n+      outbuf = open(LOG_LOC, O_CREAT | O_WRONLY);\n     } else {\n \t\t/*\n \t\t* TODO: Make better file checks.\n \t\t*/\n-\t  outbuf = open(LOG_LOC, O_APPEND); // Else, assume file already exist: Open to append.\n-\t}\n-\n-    /*\n-      Checking is done, now we will write to the KMSG.\n-    */\n-\n-      strcpy(buf,\"COULD NOT OPEN KMSG PLEASE FIX\");\n-\n+\t  outbuf = open(LOG_LOC, O_APPEND);\n+      strcpy(tag,\"COULD NOT OPEN KMSG PLEASE FIX\");\n     }\n+  }\n+\tret = write(outbuf, tag, strlen(tag) );\n+\tclose(outbuf);\n \n-\tret = write(outbuf, buf, strlen(buf) ); // Write \"Test\" to KMSG\n-\n-\tclose(outbuf); // CLOSE THE FILE DISCRIPTOR TO AVOID LEAK ;\n-\n-\tfree(buf); // Empty buf memory.","path":"C/kmsg_log.c","position":98,"original_position":89,"commit_id":"d2c88abff0418900c26ff9f34d583d5d1f87794b","original_commit_id":"d2c88abff0418900c26ff9f34d583d5d1f87794b","user":{"login":"nailyk-fr","id":16372405,"avatar_url":"https://avatars.githubusercontent.com/u/16372405?v=3","gravatar_id":"","url":"https://api.github.com/users/nailyk-fr","html_url":"https://github.com/nailyk-fr","followers_url":"https://api.github.com/users/nailyk-fr/followers","following_url":"https://api.github.com/users/nailyk-fr/following{/other_user}","gists_url":"https://api.github.com/users/nailyk-fr/gists{/gist_id}","starred_url":"https://api.github.com/users/nailyk-fr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nailyk-fr/subscriptions","organizations_url":"https://api.github.com/users/nailyk-fr/orgs","repos_url":"https://api.github.com/users/nailyk-fr/repos","events_url":"https://api.github.com/users/nailyk-fr/events{/privacy}","received_events_url":"https://api.github.com/users/nailyk-fr/received_events","type":"User","site_admin":false},"body":"no free(tag)?","created_at":"2017-01-26T16:03:26Z","updated_at":"2017-01-26T16:05:59Z","html_url":"https://github.com/Carbon-Fusion/lib-le-log/pull/7#discussion_r98025946","pull_request_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/comments/98025946"},"html":{"href":"https://github.com/Carbon-Fusion/lib-le-log/pull/7#discussion_r98025946"},"pull_request":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7","id":102893086,"html_url":"https://github.com/Carbon-Fusion/lib-le-log/pull/7","diff_url":"https://github.com/Carbon-Fusion/lib-le-log/pull/7.diff","patch_url":"https://github.com/Carbon-Fusion/lib-le-log/pull/7.patch","issue_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues/7","number":7,"state":"open","locked":false,"title":"Adopt a new way to go with the loglevels","user":{"login":"DevUt","id":17984792,"avatar_url":"https://avatars.githubusercontent.com/u/17984792?v=3","gravatar_id":"","url":"https://api.github.com/users/DevUt","html_url":"https://github.com/DevUt","followers_url":"https://api.github.com/users/DevUt/followers","following_url":"https://api.github.com/users/DevUt/following{/other_user}","gists_url":"https://api.github.com/users/DevUt/gists{/gist_id}","starred_url":"https://api.github.com/users/DevUt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevUt/subscriptions","organizations_url":"https://api.github.com/users/DevUt/orgs","repos_url":"https://api.github.com/users/DevUt/repos","events_url":"https://api.github.com/users/DevUt/events{/privacy}","received_events_url":"https://api.github.com/users/DevUt/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-01-24T10:45:42Z","updated_at":"2017-01-26T16:05:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2dd85c92feeb826e67a61187cd74bf1b6dc59fe","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7/commits","review_comments_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7/comments","review_comment_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues/7/comments","statuses_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/statuses/d2c88abff0418900c26ff9f34d583d5d1f87794b","head":{"label":"DevUt:new-clean","ref":"new-clean","sha":"d2c88abff0418900c26ff9f34d583d5d1f87794b","user":{"login":"DevUt","id":17984792,"avatar_url":"https://avatars.githubusercontent.com/u/17984792?v=3","gravatar_id":"","url":"https://api.github.com/users/DevUt","html_url":"https://github.com/DevUt","followers_url":"https://api.github.com/users/DevUt/followers","following_url":"https://api.github.com/users/DevUt/following{/other_user}","gists_url":"https://api.github.com/users/DevUt/gists{/gist_id}","starred_url":"https://api.github.com/users/DevUt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevUt/subscriptions","organizations_url":"https://api.github.com/users/DevUt/orgs","repos_url":"https://api.github.com/users/DevUt/repos","events_url":"https://api.github.com/users/DevUt/events{/privacy}","received_events_url":"https://api.github.com/users/DevUt/received_events","type":"User","site_admin":false},"repo":{"id":79901290,"name":"lib-le-log","full_name":"DevUt/lib-le-log","owner":{"login":"DevUt","id":17984792,"avatar_url":"https://avatars.githubusercontent.com/u/17984792?v=3","gravatar_id":"","url":"https://api.github.com/users/DevUt","html_url":"https://github.com/DevUt","followers_url":"https://api.github.com/users/DevUt/followers","following_url":"https://api.github.com/users/DevUt/following{/other_user}","gists_url":"https://api.github.com/users/DevUt/gists{/gist_id}","starred_url":"https://api.github.com/users/DevUt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevUt/subscriptions","organizations_url":"https://api.github.com/users/DevUt/orgs","repos_url":"https://api.github.com/users/DevUt/repos","events_url":"https://api.github.com/users/DevUt/events{/privacy}","received_events_url":"https://api.github.com/users/DevUt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DevUt/lib-le-log","description":"This lib tries to make a more clear and unified way of logging stuff in Android","fork":true,"url":"https://api.github.com/repos/DevUt/lib-le-log","forks_url":"https://api.github.com/repos/DevUt/lib-le-log/forks","keys_url":"https://api.github.com/repos/DevUt/lib-le-log/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DevUt/lib-le-log/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DevUt/lib-le-log/teams","hooks_url":"https://api.github.com/repos/DevUt/lib-le-log/hooks","issue_events_url":"https://api.github.com/repos/DevUt/lib-le-log/issues/events{/number}","events_url":"https://api.github.com/repos/DevUt/lib-le-log/events","assignees_url":"https://api.github.com/repos/DevUt/lib-le-log/assignees{/user}","branches_url":"https://api.github.com/repos/DevUt/lib-le-log/branches{/branch}","tags_url":"https://api.github.com/repos/DevUt/lib-le-log/tags","blobs_url":"https://api.github.com/repos/DevUt/lib-le-log/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DevUt/lib-le-log/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DevUt/lib-le-log/git/refs{/sha}","trees_url":"https://api.github.com/repos/DevUt/lib-le-log/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DevUt/lib-le-log/statuses/{sha}","languages_url":"https://api.github.com/repos/DevUt/lib-le-log/languages","stargazers_url":"https://api.github.com/repos/DevUt/lib-le-log/stargazers","contributors_url":"https://api.github.com/repos/DevUt/lib-le-log/contributors","subscribers_url":"https://api.github.com/repos/DevUt/lib-le-log/subscribers","subscription_url":"https://api.github.com/repos/DevUt/lib-le-log/subscription","commits_url":"https://api.github.com/repos/DevUt/lib-le-log/commits{/sha}","git_commits_url":"https://api.github.com/repos/DevUt/lib-le-log/git/commits{/sha}","comments_url":"https://api.github.com/repos/DevUt/lib-le-log/comments{/number}","issue_comment_url":"https://api.github.com/repos/DevUt/lib-le-log/issues/comments{/number}","contents_url":"https://api.github.com/repos/DevUt/lib-le-log/contents/{+path}","compare_url":"https://api.github.com/repos/DevUt/lib-le-log/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DevUt/lib-le-log/merges","archive_url":"https://api.github.com/repos/DevUt/lib-le-log/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DevUt/lib-le-log/downloads","issues_url":"https://api.github.com/repos/DevUt/lib-le-log/issues{/number}","pulls_url":"https://api.github.com/repos/DevUt/lib-le-log/pulls{/number}","milestones_url":"https://api.github.com/repos/DevUt/lib-le-log/milestones{/number}","notifications_url":"https://api.github.com/repos/DevUt/lib-le-log/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DevUt/lib-le-log/labels{/name}","releases_url":"https://api.github.com/repos/DevUt/lib-le-log/releases{/id}","deployments_url":"https://api.github.com/repos/DevUt/lib-le-log/deployments","created_at":"2017-01-24T10:27:58Z","updated_at":"2017-01-24T10:28:00Z","pushed_at":"2017-01-26T10:38:39Z","git_url":"git://github.com/DevUt/lib-le-log.git","ssh_url":"git@github.com:DevUt/lib-le-log.git","clone_url":"https://github.com/DevUt/lib-le-log.git","svn_url":"https://github.com/DevUt/lib-le-log","homepage":"","size":43,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"Carbon-Fusion:new-clean","ref":"new-clean","sha":"6e0fab6f195be3dbc761655248cf3688fbedaee8","user":{"login":"Carbon-Fusion","id":24204762,"avatar_url":"https://avatars.githubusercontent.com/u/24204762?v=3","gravatar_id":"","url":"https://api.github.com/users/Carbon-Fusion","html_url":"https://github.com/Carbon-Fusion","followers_url":"https://api.github.com/users/Carbon-Fusion/followers","following_url":"https://api.github.com/users/Carbon-Fusion/following{/other_user}","gists_url":"https://api.github.com/users/Carbon-Fusion/gists{/gist_id}","starred_url":"https://api.github.com/users/Carbon-Fusion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carbon-Fusion/subscriptions","organizations_url":"https://api.github.com/users/Carbon-Fusion/orgs","repos_url":"https://api.github.com/users/Carbon-Fusion/repos","events_url":"https://api.github.com/users/Carbon-Fusion/events{/privacy}","received_events_url":"https://api.github.com/users/Carbon-Fusion/received_events","type":"Organization","site_admin":false},"repo":{"id":75547335,"name":"lib-le-log","full_name":"Carbon-Fusion/lib-le-log","owner":{"login":"Carbon-Fusion","id":24204762,"avatar_url":"https://avatars.githubusercontent.com/u/24204762?v=3","gravatar_id":"","url":"https://api.github.com/users/Carbon-Fusion","html_url":"https://github.com/Carbon-Fusion","followers_url":"https://api.github.com/users/Carbon-Fusion/followers","following_url":"https://api.github.com/users/Carbon-Fusion/following{/other_user}","gists_url":"https://api.github.com/users/Carbon-Fusion/gists{/gist_id}","starred_url":"https://api.github.com/users/Carbon-Fusion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carbon-Fusion/subscriptions","organizations_url":"https://api.github.com/users/Carbon-Fusion/orgs","repos_url":"https://api.github.com/users/Carbon-Fusion/repos","events_url":"https://api.github.com/users/Carbon-Fusion/events{/privacy}","received_events_url":"https://api.github.com/users/Carbon-Fusion/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Carbon-Fusion/lib-le-log","description":"This lib tries to make a more clear and unified way of logging stuff in Android","fork":false,"url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log","forks_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/forks","keys_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/teams","hooks_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/hooks","issue_events_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues/events{/number}","events_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/events","assignees_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/assignees{/user}","branches_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/branches{/branch}","tags_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/tags","blobs_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/git/refs{/sha}","trees_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/statuses/{sha}","languages_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/languages","stargazers_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/stargazers","contributors_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/contributors","subscribers_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/subscribers","subscription_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/subscription","commits_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/commits{/sha}","git_commits_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/git/commits{/sha}","comments_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/comments{/number}","issue_comment_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues/comments{/number}","contents_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/contents/{+path}","compare_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/merges","archive_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/downloads","issues_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues{/number}","pulls_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls{/number}","milestones_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/milestones{/number}","notifications_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/labels{/name}","releases_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/releases{/id}","deployments_url":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/deployments","created_at":"2016-12-04T15:51:44Z","updated_at":"2016-12-31T08:03:03Z","pushed_at":"2017-01-26T10:38:40Z","git_url":"git://github.com/Carbon-Fusion/lib-le-log.git","ssh_url":"git@github.com:Carbon-Fusion/lib-le-log.git","clone_url":"https://github.com/Carbon-Fusion/lib-le-log.git","svn_url":"https://github.com/Carbon-Fusion/lib-le-log","homepage":"","size":37,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7"},"html":{"href":"https://github.com/Carbon-Fusion/lib-le-log/pull/7"},"issue":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues/7"},"comments":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/Carbon-Fusion/lib-le-log/statuses/d2c88abff0418900c26ff9f34d583d5d1f87794b"}}}}
{"actor":{"display_login":"nailyk-fr"}}