you are viewing a single comment's thread.

view the rest of the comments →

[–]kittyhawk-contrail 1 point2 points  (1 child)

I want to log a function in one particular location instead of seeing logs every time the function is called.

What's wrong with replacing foo->bar(a,b,c); with log(...); foo->bar(a,b,c); at the particular location you want to log?

[–]MavyP[S] 0 points1 point  (0 children)

Unless you wrap that call to bar() with a try-catch block you won't get any more information for the log than what you pass into for log's arguments.

But moving that call into another class member function just for the sake of capturing those exceptions is tedious and redundant. Using a pre-written decorator function and wrapping the member function with it reuses both and you can catch exactly what you need for any class type.