Skip to content

feat: FileLogger. A small utility to log to a file identified by proc…#481

Merged
jeffreyrainy merged 4 commits intodevelopfrom
feature/filelogger
Feb 17, 2021
Merged

feat: FileLogger. A small utility to log to a file identified by proc…#481
jeffreyrainy merged 4 commits intodevelopfrom
feature/filelogger

Conversation

@jeffreyrainy
Copy link
Copy Markdown
Contributor

…ess ID. Useful when running multiple instances locally

…ess ID. Useful when running multiple instances locally
Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
Comment on lines +24 to +27
~FileLogger()
{
writer.Close();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this, you should implement IDisposable with Dispose() method instead and put writer.Dispose() in it.
I also believe you could set AutoFlush to false and expose Flush() API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the dispose.
But not with the AutoFlush. Since this is debug functionality, you want the info to get out asap. You might be stopped on a breakpoint soon after, or get other crash/exceptions. Auto-flushing comes at very little cost and provides peace-of-mind that you'll get your logs.

Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
@LukeStampfli
Copy link
Copy Markdown
Contributor

LukeStampfli commented Feb 12, 2021

Would this maybe be something which we want to put in the community-contributions repository instead of core MLAPI? Because it's not really related to MLAPI directly but more like a separate extension.

@jeffreyrainy
Copy link
Copy Markdown
Contributor Author

Would this maybe be something which we want to put in the community-contributions repository instead of core MLAPI Because it's not really related to MLAPI directly but more like a separate extension.

I could agree, but what I'm after, here, is not just having a tool for myself. I'm trying to get a common set of tools that are already there and ready. So, for example, if there's a discussion between two developers and they want to test which approach is better, either one can just drop in a FileLogger::Get().Log("blah"), in any branch, on any project. If one has to install/add something else it defeats the whole purpose, in my view.

I'd totally buy "This doesn't belong in mlapi" and would keep it local for me. I'd accept this, no issue.
I wish we can have "This is not strictly mlapi, but it's a nice tool that will be ready and available"
But, "put it in a contrib beside" is a bit unsatisfactory, tbh.

Comment thread com.unity.multiplayer.mlapi/Runtime/Logging/FileLogger.cs Outdated
Copy link
Copy Markdown
Contributor

@0xFA11 0xFA11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Copy link
Copy Markdown
Contributor

@mattwalsh-unity mattwalsh-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffreyrainy jeffreyrainy merged commit 6b1de43 into develop Feb 17, 2021
@jeffreyrainy jeffreyrainy deleted the feature/filelogger branch February 17, 2021 20:22
jeffreyrainy added a commit that referenced this pull request Feb 18, 2021
jeffreyrainy added a commit that referenced this pull request Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants