zaptst / zap

A streamable structured interface for real time reporting of developer tools.
MIT License
120 stars 1 forks source link

replace source/message w/ content #6

Closed jamiebuilds closed 6 years ago

jamiebuilds commented 6 years ago

This makes events far more expressive, giving them the ability to have multi-part messages which target multiple different kinds of source locations.

Before:

interface Event {
  kind: string,
  event: string,
  id: string,
  source: string,
  message: string,
  timestamp: string,
}

After:

interface Event {
  kind: string,
  event: string,
  id: string,
  timestamp: string,
  content: Array<{
    message: string,
    loc?: Array<{
      file: string,
      start?: { row: number, col?: number },
      end?: { row: number, col?: number },
    }>,
  }>,
}

cc @sholladay @sindresorhus

sindresorhus commented 6 years ago

Generally looks good 👍

I would change col => column. I don't see the point of shortening that.

loc is not that clear. What is it even short for? I would maybe name it source.

sholladay commented 6 years ago

I'm not entirely convinced that content is a necessary layer of nesting, but I get the idea. I don't think I'm ever going to have more than one array item in there for any of my own use cases, at least. But it's also not much of a burden, so it's fine.

I'm pretty happy with these changes overall. Love that loc is an array and that col is optional.

I agree with Sindre on changing the names to a non-abbreviated form.