Skip to content

feature: define tracing - log inputs and outputs #3

Description

@aoancea

This decorator is going to support the logging of inputs and outputs of every method from a class, thus, I define the following interface and its implementation:

public interface IFoo
{
    string Bar(string text);
}

public class Foo : IFoo
{
    public string Bar(string text)
    {
        return text;
    }
}

Given the above interface, I define the following decorator

public class Foo_IO_Decorator : IFoo
{
    private readonly IFoo decorated;

    public Foo_IO_Decorator(IFoo decorated)
    {
        this.decorated = decorated;
    }

    public string Bar(string text)
    {
        // TODO: provide a mechanics to log the input
        string result = decorated.Bar(text);
        // TODO: provide a mechanics to log the output

        return result;
    }
}

Note: For methods which don't accept any parameters or return void, input and respectively output logging will be NOT be performed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions