I am experimenting with a debug logging tool, and I want each run of a function to print out the Class Name, instance, function name, and its parameters. This is what I have so far
class Object {
func exampleFunction(parameter1: String, parameter2: Int) {
print("\(self.dynamicType)."+__FUNCTION__+"( <TODO: INSERT ALL PARAMETERS HERE AUTOMAGICALLY> )")
//do function stuff
}
}
Is there a way I can get the parameter list dynamically the similarly to how I get the function name and class type?
EDIT: I found this question on stack overflow that is trying to do a similar thing, but they don't know how to get the parameters.
The only official documentation on those literals is here
Which only describes about the following
__FILE__ The name of the file in which it appears.
__LINE__ The line number on which it appears.
__COLUMN__ The column number in which it begins.
__FUNCTION__ The name of the declaration in which it appears.
So i guess you cannot get the method parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With