1
submitted 5 months ago* (last edited 5 months ago) by bluGill@kbin.social to c/programming@kbin.social

Have you ever mocked your logger in a test, or wished you could? That is something like

TEST(some test name)

    mockLogger logger

    logger.expect_call(log("some string"))

    DoSomething(logger)

#programming

you are viewing a single comment's thread
view the rest of the comments
[-] tve@mastodon.social 0 points 5 months ago

@bluGill If you have a need to mock a logger, you probably should have an interface dedicated to those logs.

It is also recommended to have dedicated loggers used in each domain, rather than allowing logging everything and everywhere, which may lead to sanitizing log inputs everywhere to be in control and not expose any security issues.

But in many cases that may also be overkill. As always, it depends.

[-] bluGill@kbin.social 1 points 5 months ago

@tve I didn't ask how to do it, I asked if anyone else has done it.

this post was submitted on 28 Mar 2024
1 points (100.0% liked)

Programming

2 readers
1 users here now

This magazine is dedicated to discussions on programming languages, software development, and coding. Whether you are a beginner programmer or an experienced developer, this is the place for you. Here you can share your knowledge, ask questions, and engage in discussions on topics such as coding languages, software engineering, web development, and more. From the latest trends and frameworks to tips and tricks for debugging, this category covers a wide range of topics related to programming.

founded 1 year ago