{"action":"created","issue":{"url":"https://api.github.com/repos/nexusdev/dapple/issues/165","repository_url":"https://api.github.com/repos/nexusdev/dapple","labels_url":"https://api.github.com/repos/nexusdev/dapple/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/nexusdev/dapple/issues/165/comments","events_url":"https://api.github.com/repos/nexusdev/dapple/issues/165/events","html_url":"https://github.com/nexusdev/dapple/pull/165","id":138494407,"number":165,"title":"WIP Advanced Logging and Reporting","user":{"login":"mhhf","id":446478,"avatar_url":"https://avatars.githubusercontent.com/u/446478?v=3","gravatar_id":"","url":"https://api.github.com/users/mhhf","html_url":"https://github.com/mhhf","followers_url":"https://api.github.com/users/mhhf/followers","following_url":"https://api.github.com/users/mhhf/following{/other_user}","gists_url":"https://api.github.com/users/mhhf/gists{/gist_id}","starred_url":"https://api.github.com/users/mhhf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhhf/subscriptions","organizations_url":"https://api.github.com/users/mhhf/orgs","repos_url":"https://api.github.com/users/mhhf/repos","events_url":"https://api.github.com/users/mhhf/events{/privacy}","received_events_url":"https://api.github.com/users/mhhf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-04T14:55:00Z","updated_at":"2016-03-10T14:57:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nexusdev/dapple/pulls/165","html_url":"https://github.com/nexusdev/dapple/pull/165","diff_url":"https://github.com/nexusdev/dapple/pull/165.diff","patch_url":"https://github.com/nexusdev/dapple/pull/165.patch"},"body":"This branch tries to improve the current logger.\r\n\r\n#### NatSpec debugger\r\nThis addresses #155 and #143\r\n\r\nIt is possible to use this statements in any solidity code:\r\n```\r\ncontract Contract {\r\n    function send (address addr, uint value) {\r\n        //@info user `address addr` has deposit `uint value`eth\r\n        [...]\r\n        //@warn something happened: \"`string message`\"\r\n    }\r\n}\r\n```\r\nWhich on **internal** chains will produce the following log output if executed:\r\n```\r\nINFO:  user 0x4cfcedde6a51e5f6b47da226e50c2bb8b055ee62 has deposit 200eth\r\nWARN:  something happened: \"a strange loop\"\r\n```\r\nOn external chains (rpc/ipc connected) the statements are treated as comments and ignored during deploy.\r\n\r\nThe statements has to have one of the following prefixes:\r\n* `//@warn`\r\n* `//@info`\r\n* `//@log`\r\n* `//@debug`\r\n\r\nExpressions which are surrounded by \"\\`\" has to be in the following form: `<type> <reference>` while\r\n__type__ has to be a valid solidity type and __reference__ points to an actual variable in your solidity code\r\n\r\n\r\n### Reporter\r\n\r\nadditional to the logging output to stdout a reporter can be enabled:\r\nIn order to use the reporter, inherit from the Reporter contract:\r\n```\r\ncontract MyTester is Reporter {\r\n[...]\r\n```\r\n\r\nduring the testSetup you have to specify an output file by calling the setupReporter function:\r\n\r\n`setupReporter('doc/report.md');`\r\n\r\nNow you can use the `//@doc` command which writes to the reporting file instead of stdout.\r\n\r\nAlso a modifier **wrapCode(string what)** is provided which wraps all output in a code block. Here an example:\r\n\r\n```\r\nfunction drawTree() wrapCode(\"dot\") {\r\n  uint numNodes = contract.numNodes();\r\n  //@doc digraph A {\r\n  for(var i=1; i<numNodes; i++) {\r\n    uint parent = contract.getParentForNode(i);\r\n    //@doc node_`uint parent` -> node_`uint i`;\r\n  }\r\n  //@doc }\r\n}\r\n```\r\n\r\nWill produce the following code in `doc/report.md`:\r\n```\r\n` ``{dot}\r\ndigraph A {\r\n  node_0 -> node_1;\r\n  node_0 -> node_2;\r\n  node_2 -> node_3;\r\n}\r\n` ``\r\n```\r\n\r\nwith a custom post-processor (like knitr) wrapped code can be further evaluated. In this case to a graphviz image:\r\n![](https://chart.googleapis.com/chart?chl=+digraph+A+%7B%0D%0A++++++node_0+-%3E+node_1%3B%0D%0A++node_0+-%3E+node_2%3B%0D%0A++node_2+-%3E+node_3%3B%0D%0A+%7D%0D%0A++++++++&cht=gv)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nexusdev/dapple/issues/comments/194887721","html_url":"https://github.com/nexusdev/dapple/pull/165#issuecomment-194887721","issue_url":"https://api.github.com/repos/nexusdev/dapple/issues/165","id":194887721,"user":{"login":"nmushegian","id":924397,"avatar_url":"https://avatars.githubusercontent.com/u/924397?v=3","gravatar_id":"","url":"https://api.github.com/users/nmushegian","html_url":"https://github.com/nmushegian","followers_url":"https://api.github.com/users/nmushegian/followers","following_url":"https://api.github.com/users/nmushegian/following{/other_user}","gists_url":"https://api.github.com/users/nmushegian/gists{/gist_id}","starred_url":"https://api.github.com/users/nmushegian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmushegian/subscriptions","organizations_url":"https://api.github.com/users/nmushegian/orgs","repos_url":"https://api.github.com/users/nmushegian/repos","events_url":"https://api.github.com/users/nmushegian/events{/privacy}","received_events_url":"https://api.github.com/users/nmushegian/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T14:57:16Z","updated_at":"2016-03-10T14:57:16Z","body":"awesome."}}