You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Change the @Trace annotations to report on parameter values and return values #797
Hello,
as mentioned here https://groups.google.com/forum/#!topic/androidannotations/2BSDWe7r6OA
it would be quite useful for the @trace annotation to create a log statement with all the values of the parameters passed in the method if they are primitives, or the .toString() representations if they are objects. I guess that the same thing could happen with the return value of a method.
Well if it’s big it’s usually cause it’s needed, so i’d say just leave it as a whole. You could also add a parameter to choose whether we want to log parameters or not. Also, I wonder if there is a way to see if the toString is actually implemented before using it, so that we don’t get the random Object@1943012390 values outputed.
Cheers,
Sakis
From: Damien
Sent: Friday, December 06, 2013 9:19 AM
To: excilys/androidannotations
Cc: athkalia
Subject: Re: [androidannotations] Change the @trace annotations to report on parameter values and return values (#797)
I agree. But what should happen if parameters are objects with big toString value ? Should we truncate the value ?
However, I'm planning this for 3.1
—
Reply to this email directly or view it on GitHub.
a simple toString does not work for primitive types and for some unknown reason JVar.type().isPrimitive() returns false for primitive parameter types like int
as both projects are Licensed Apache 2.0 i think @JakeWharton would agree to use the class here. for sure i would add copyright headers mentioning him instead of eBusiness Information, Excilys Group like in the other AA files.
Hmm, do we already have imported files with non-Excilys license headers? BTW, i really do not know the policy about this, hope @DayS can give us some advice here.
The license header will be overwritten by a mvn license:check. So, it's not so easy to include it.
What about generating the relevant part of Strings.toString() ?
I mean generating :
'"' + str + '"', if the param str is a String
Arrays.toString(intArray), if the param intArray is an array of int
etc..
It would be more efficient and prevent us from managing two license.
I don't think we should handle complex cases like arrays of arrays.
It's not a common use case, won't be very readable in logs and will be slower at runtime.
I think we should handle primitive types, Strings, Arrays. For other parameters, we should call toString().
It will handle most of the cases and for others, the developer can still use a debugger.
I think you are right. For arrays, i guess you just want to call Arrays.toString, and do not care about nested arrays or such. If we do like you suggested, we do not have to include foreign code.
Activity
DayS commentedon Dec 6, 2013
I agree. But what should happen if parameters are objects with big toString value ? Should we truncate the value ?
However, I'm planning this for 3.1
athkalia commentedon Dec 6, 2013
Well if it’s big it’s usually cause it’s needed, so i’d say just leave it as a whole. You could also add a parameter to choose whether we want to log parameters or not. Also, I wonder if there is a way to see if the toString is actually implemented before using it, so that we don’t get the random Object@1943012390 values outputed.
Cheers,
Sakis
From: Damien
Sent: Friday, December 06, 2013 9:19 AM
To: excilys/androidannotations
Cc: athkalia
Subject: Re: [androidannotations] Change the @trace annotations to report on parameter values and return values (#797)
I agree. But what should happen if parameters are objects with big toString value ? Should we truncate the value ?
However, I'm planning this for 3.1
—
Reply to this email directly or view it on GitHub.
dodgex commentedon Aug 21, 2014
I just started to work on this issue. Most of the code is done.
for the parameter values i would like to use the Strings class of JakeWharton/hugo.
a simple
toStringdoes not work for primitive types and for some unknown reasonJVar.type().isPrimitive()returns false for primitive parameter types likeintas both projects are Licensed Apache 2.0 i think @JakeWharton would agree to use the class here. for sure i would add copyright headers mentioning him instead of
eBusiness Information, Excilys Grouplike in the other AA files.dodgex commentedon Aug 21, 2014
when i'm allowed to use the Strings class, it would go to
org.androidannotations.api.Stringsas it is needed in runtime.would produce (truncated)
dodgex commentedon Aug 21, 2014
when i get an OK for using the Strings class and for the generated output, i'll create a PR for this changes.
WonderCsabo commentedon Aug 22, 2014
Hmm, do we already have imported files with non-Excilys license headers? BTW, i really do not know the policy about this, hope @DayS can give us some advice here.
yDelouis commentedon Aug 22, 2014
The license header will be overwritten by a
mvn license:check. So, it's not so easy to include it.What about generating the relevant part of
Strings.toString()?I mean generating :
'"' + str + '"', if the paramstris aStringArrays.toString(intArray), if the paramintArrayis anarrayofintIt would be more efficient and prevent us from managing two license.
WonderCsabo commentedon Aug 22, 2014
@yDelouis The
Stringsclass has indeed complex methods, for exampledeepArrayToString(). Is it a good idea to generate those?yDelouis commentedon Aug 22, 2014
I don't think we should handle complex cases like arrays of arrays.
It's not a common use case, won't be very readable in logs and will be slower at runtime.
I think we should handle primitive types, Strings, Arrays. For other parameters, we should call
toString().It will handle most of the cases and for others, the developer can still use a debugger.
yDelouis commentedon Aug 22, 2014
A side note,
long start = System.currentTimeMillis();should be after loggingEntering ....WonderCsabo commentedon Aug 22, 2014
I think you are right. For arrays, i guess you just want to call
Arrays.toString, and do not care about nested arrays or such. If we do like you suggested, we do not have to include foreign code.dodgex commentedon Aug 22, 2014
@yDelouis @WonderCsabo ok, so we'll go with the simple way without the
Stringsclass?@yDelouis i haven't changed the calling order just added the paramerters. but i fix/can change it in my PR then.
WonderCsabo commentedon Aug 22, 2014
I think yes, we should generate the calls like @yDelouis laid out in this comment.
dodgex commentedon Aug 22, 2014
okay.
1 remaining item
WonderCsabo commentedon Aug 23, 2014
Do not panic. It is possible to still restore your branch locally. See here or here.
dodgex commentedon Aug 23, 2014
@WonderCsabo you are my hero. <3
good that i was doing some other stuff instead of rebuilding the changes. :)
dodgex commentedon Aug 23, 2014
generates to:
with this log output:
WonderCsabo commentedon Aug 23, 2014
Please create a pull request, we discuss implementation there and will refactor if that is need.
dodgex commentedon Aug 23, 2014
i just realized that this issue also requested to log the return value. should i implement that too? :)
WonderCsabo commentedon Aug 23, 2014
Why not? @yDelouis ?
dodgex commentedon Aug 23, 2014
updated the PR.
yDelouis commentedon Aug 23, 2014
Sure, why not.
WonderCsabo commentedon Sep 22, 2014
This was implemented. :)