You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
Let's assume I'm working on a large program and one team wants objects to log with one format and another team wants to log with another format, but both want to log with the same file. I could have the object's constructor instantiate a logger or have a static logger for the class, but then I have the same question of do I make the file path variable and other shared configs global or do I pass it into every class/object?StaticMethod– StaticMethod2023-07-14 15:20:31 +00:00Commented Jul 14, 2023 at 15:20
-
@StaticMethod: whatever suits your requirements best, as long as it keeps the risk of getting unwanted side effects low.Doc Brown– Doc Brown2023-07-14 15:36:30 +00:00Commented Jul 14, 2023 at 15:36
-
I would say that different modules can have different logging requirements if they are running on separate microservices. One deployed service should have a clear requirement that the sys admin can manage. It is the person who executes the deployment who has to care for disk space and all the other details, not the developer.FluidCode– FluidCode2023-07-14 17:22:59 +00:00Commented Jul 14, 2023 at 17:22
-
@FluidCode: your comment seems to be off-track, since making the configuration of a logger available to an admin at run time is 100% orthogonal to the decision "global variable vs DI". Or in other words, this has nothing to do with the question.Doc Brown– Doc Brown2023-07-14 18:41:12 +00:00Commented Jul 14, 2023 at 18:41
-
This is also perfectly fine for enormous programs. Logging should just not have side effects or state that can be read. As simple as that. Console.WriteLine is a logger. Unity’s Debug.log is a logger. There might be very special cases and parts where you want to inject your logger but also in large applications it is 99% unnecesary boiler plate.Dirk Boer– Dirk Boer2023-07-15 21:30:07 +00:00Commented Jul 15, 2023 at 21:30
|
Show 3 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you