{"action":"created","issue":{"url":"https://api.github.com/repos/RoboJackets/robocup-software/issues/491","repository_url":"https://api.github.com/repos/RoboJackets/robocup-software","labels_url":"https://api.github.com/repos/RoboJackets/robocup-software/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/RoboJackets/robocup-software/issues/491/comments","events_url":"https://api.github.com/repos/RoboJackets/robocup-software/issues/491/events","html_url":"https://github.com/RoboJackets/robocup-software/issues/491","id":114975123,"number":491,"title":"stream-based logging for firmware","user":{"login":"justbuchanan","id":115131,"avatar_url":"https://avatars.githubusercontent.com/u/115131?v=3","gravatar_id":"","url":"https://api.github.com/users/justbuchanan","html_url":"https://github.com/justbuchanan","followers_url":"https://api.github.com/users/justbuchanan/followers","following_url":"https://api.github.com/users/justbuchanan/following{/other_user}","gists_url":"https://api.github.com/users/justbuchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/justbuchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justbuchanan/subscriptions","organizations_url":"https://api.github.com/users/justbuchanan/orgs","repos_url":"https://api.github.com/users/justbuchanan/repos","events_url":"https://api.github.com/users/justbuchanan/events{/privacy}","received_events_url":"https://api.github.com/users/justbuchanan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RoboJackets/robocup-software/labels/Easy","name":"Easy","color":"fef2c0"},{"url":"https://api.github.com/repos/RoboJackets/robocup-software/labels/firmware","name":"firmware","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"JNeiger","id":5797304,"avatar_url":"https://avatars.githubusercontent.com/u/5797304?v=3","gravatar_id":"","url":"https://api.github.com/users/JNeiger","html_url":"https://github.com/JNeiger","followers_url":"https://api.github.com/users/JNeiger/followers","following_url":"https://api.github.com/users/JNeiger/following{/other_user}","gists_url":"https://api.github.com/users/JNeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/JNeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JNeiger/subscriptions","organizations_url":"https://api.github.com/users/JNeiger/orgs","repos_url":"https://api.github.com/users/JNeiger/repos","events_url":"https://api.github.com/users/JNeiger/events{/privacy}","received_events_url":"https://api.github.com/users/JNeiger/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-11-04T05:45:29Z","updated_at":"2016-02-17T02:14:44Z","closed_at":null,"body":"The more or less \"standard\" way of doing logging in C++ is with streams.  We implemented something this a while ago, but I think some of it got lost due to merge conflicts.  It'd be nice to be able to something like this in firmware:\r\n~~~{.cpp}\r\nLOG(WARN) << \"Something happened to: \" << myObject << endl;\r\n~~~\r\n\r\nThe real power here is that you can implement `operator<<(ostream)` on different classes and very easily print them to the log."},"comment":{"url":"https://api.github.com/repos/RoboJackets/robocup-software/issues/comments/184978423","html_url":"https://github.com/RoboJackets/robocup-software/issues/491#issuecomment-184978423","issue_url":"https://api.github.com/repos/RoboJackets/robocup-software/issues/491","id":184978423,"user":{"login":"JNeiger","id":5797304,"avatar_url":"https://avatars.githubusercontent.com/u/5797304?v=3","gravatar_id":"","url":"https://api.github.com/users/JNeiger","html_url":"https://github.com/JNeiger","followers_url":"https://api.github.com/users/JNeiger/followers","following_url":"https://api.github.com/users/JNeiger/following{/other_user}","gists_url":"https://api.github.com/users/JNeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/JNeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JNeiger/subscriptions","organizations_url":"https://api.github.com/users/JNeiger/orgs","repos_url":"https://api.github.com/users/JNeiger/repos","events_url":"https://api.github.com/users/JNeiger/events{/privacy}","received_events_url":"https://api.github.com/users/JNeiger/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T02:14:44Z","updated_at":"2016-02-17T02:14:44Z","body":"So I overloaded the `log(...)` function within the [`logger.hpp`](https://github.com/RoboJackets/robocup-software/blob/robot2015-firmware/firmware/common2015/utils/logger/logger.hpp) class to allow for a `std::ostream&` type overload (mirroring [this](https://github.com/RoboJackets/robocup-software/blob/master/firmware/common2015/utils/Logger/logger.hpp#L40) function in the old code).\r\n\r\nSince both of these are going to be called through the [`LOG(...)`](https://github.com/RoboJackets/robocup-software/blob/robot2015-firmware/firmware/common2015/utils/logger/logger.hpp#L24-L25) macro, I think the next step is to \"overload\" the macro so it can call both depending on there are any arguments besides the log level. Most likely loosely mirroring this style of [design pattern](http://stackoverflow.com/questions/8886812/overload-c-macros). \r\n\r\n@justbuchanan, Would that be the right way to go on this or is there a better way?"}}