Tech Off Post

Single Post Permalink

View Thread: Getting current method name in C# similar to __FUNCTION__ in C
  • User profile image
    Ion Todirel

    @BitFlipper: If you have a logger, you shouldn't expose this glue outside the logger, make it transparent. So you need the caller not the current function name.

    void Foo() {
        this.Log("something happened")
    }

    void Log(string message) {
        LogInternal(string.Format("[timestamp] callerName message", ...));
    }