rojo-rbx / run-in-roblox

Run a place, model, or individual script inside Roblox Studio, integrating with command line tools
MIT License
53 stars 22 forks source link

Capture relevant logs only #17

Closed OrbitalOwen closed 4 years ago

OrbitalOwen commented 4 years ago

Issue

Presently, run-in-roblox uses LogService to capture messages. This is good, because it allows its output to correspond exactly to the one in Roblox.

However, it also means logs not relevant to --script are captured. This could cause run-in-roblox to exit non-zero due to an error from an other plugin, or perhaps an issue downloading sounds (unsure if these are still error context).

We can use the xpcall calls to capture the errors from our script, and no longer listen to LogService errors to ignore others. However, with some logs being captured outside of LogService, this would lead to ordering issues as the LogService event does not fire syncronously. For example, we might see a print before an error appear after it.

Proposed soloution

The approach I have taken here is stubbing print and warn in the users code being executed. This way, we can ensure they will arrive in the correct order. There are still a few downsides with this:

This isn't a clear cut one, so I'm completely open to alternative approaches here.

OrbitalOwen commented 4 years ago

On further discussion - there's a few cases where having logs from other sources may be desirable. For example - what if a module was required elsewhere before our script? What if run-in-roblox actually ran the game in the future, and you wanted to see how one script interacted with others?

We can solve the exiting non-zero on irrelevant errors by having an explicit exit event that is triggered by the xpcall failiures. We could even inject an exit function into the users script to give them the flexibility to trigger it without having to throw an error.