Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Add logging #1

Open
mattwynne opened this issue Aug 29, 2018 · 1 comment
Open

Add logging #1

mattwynne opened this issue Aug 29, 2018 · 1 comment

Comments

@mattwynne
Copy link
Contributor

mattwynne commented Aug 29, 2018

@jbpros I wanted to start a conversation about logging.

I've been thinking we could configure a logger like this:

const { configure } = require('feynman')
configure(config => config.logger = console)

Then we should be able to see task descriptions coming out:

Given a user named Dave with email 'dave@example.com'
  Actor dave:
    Create a user named 'dave' with email 'dave@example.com'

Now that leaves us with how to log the bare (inter)action functions.

If you imagine defining an action like SignUp that then uses some browser interactions, it might look like this at the moment:

const SignUp = (
  as: name => ({ actor }) => 
    actor.attemptsTo(Follow.link("Sign up"), FillIn.fieldLabelled("Username").with(name))
}

We won't be able to log any of these, because (as far as I understand it) we can't ask the action function what the names of the wrapping functions / constants were that it was created by.

But we also want to keep the mechanism of defining these actions super lightweight, because the whole essence of this pattern, as I see it, is having lots and lots of these small compose-able actions, so we want to have minimal overhead on making new ones.

So could we make it possible to do this?

const { SignUp } = actions({ SignUp: ({
  as: name => ({ actor }) => 
    actor.attemptsTo(Follow.link("Sign up"), FillIn.fieldLabelled("Username").with(name))
  })
})

The actions method would return a proxy that decorated the action function with a description built from the calls that had been made through the proxy to access the builder functions. That way we'd then be able to log it nicely, and we'd minimise the barrier to building new actions.

WDYT? Am I making sense?

mattwynne added a commit that referenced this issue Sep 12, 2018
@mattwynne
Copy link
Contributor Author

@jbpros I think we want indentation before we call this done, WDYT?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant