-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Roslibjs logging 211 #299
Roslibjs logging 211 #299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very hot @vashmata . Honestly I'm very impressed by this PR. It looks clean
I've made some significant refactorings to hopefully clean the code up more |
Co-authored-by: MartensCedric <cedricmartens98@gmail.com>
@PeterGhimself I approved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to include a step by step instruction on how to actually test your code. Just add it to your PR description and I'll test it right after.
@@ -188,6 +204,76 @@ function initRosWeb () { | |||
} | |||
|
|||
/* functions used in main code */ | |||
|
|||
function rosTimestamp () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding any new function good practice is to add a docstring for it.
Please add a high level overview of what each function does, in a sentence or two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PeterGhimself It looks like I did add a docstring. Did I do it right?
let currentTime = new Date() | ||
let secs = currentTime.getTime()/1000 // seconds before truncating the decimal | ||
let secsFloored = Math.floor(secs) // seconds after truncating | ||
let nsecs = Math.round(1000000000*(secs-secsFloored)) // nanoseconds since the previous second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say rename this nanoSecs
to make the name clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
logData = {} | ||
logData[ROSDEBUG] = {prefix : '[DEBUG]', isError : false} | ||
logData[ROSINFO] = {prefix : '[INFO]', isError : false} | ||
logData[ROSWARN] = {prefix : '[WARN]', isError : true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets do two things:
- since semantically (and like in C++) warnings != erros this
isError
should befalse
- we should use
console.warn('something')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dealt with
stamps = rosTimestamp() | ||
consoleMsg = logData[logLevel].prefix + ' [' + stamps[1] + ']: ' + message | ||
|
||
!logData[logLevel].isError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler is better. Either make if else statement or write a comment (in English) explaining what's going on plz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dealt with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to open the issues of what you wrote on the PR if you want them to get implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignee Section
hi it me
Description
Created js functions for logging to mimic rospy functions: logInfo, logWarn, logErr, logFatal
These all call rosLog which is assisted by rosTimeStamp and publishRosLog. A new publisher was created so that these functions all log to /rosout. In practice this means you'll find the logs in rosout.log on the computer which is running as ROS MASTER. The functions include the timestamp and the log level.
I've left some todos. Most of them are bonus features that aren't necessarily required. However one missing aspect is the logic for activating/deactivating logDebug as this would need some discussion on where we put the variable that handles this.
How to Test:
rosgui
andstartgui
/rosout
:rostopic echo /rosout
[<loglevel>] [<timestamp>]: <message>
are shown:~/.ros/log/latest/rosout.log
. May require that you close roscore (and possibly all the other ros scripts) before the logfile is updatedFuture potential issues:
rospy.init_node(nodeName, log_level=rospy.DEBUG)
(addressed in Arm motor stutters when the page has been loaded for a while #321)closes #211
Approval from at least one software team lead is necessary before merging.
Reviewer Section
Aside from local testing and the General Integration Test it is implied that static analysis should be included in the verification process.
For Pull Requests that do not include code changes, it is not required to perform the tests above.