8000 Performance · Issue #18 · bengeisler/TcLog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Performance #18
Open
Open
@iadonkey

Description

@iadonkey

Hi!

this is not an issue, but only a discussion…
At Zeugwerk we have a pretty similar logger and are currently implementing a fluent API for it (atm our API is not fluent) - in general our logging mechanism has some major differences to TcLog, because we don’t use a singleton pattern, but allow several loggers to be used in a single PLC and require logging into multiple log targets to be thread-safe.

I played around a bit on how to implement the fluent API for it and found that having the log level as the first call can improve the performance a lot.
Our API, coming with Zeugwerk Framework 1.6, will look like this

_logger.AtInfo().LogMessage('I am a log message);
_logger.AtTrace().WithCondition(boolean1).Append('Number ').AppendInt(5).Append(' is alive').LogMessage('');
_logger.AtWarning().WithRisingTrigger(boolean1).LogMessage('boolean1 just got true');

having the log level as the „initiating“ call to the fluent API, has the advantage that a log message can be immediately discarded if the minimum log level as not satisfied, also if any „with“ condition is not met the message can be discarded. A discarded message doesn’t need any string operations, so besides the calls to the methods and an „if discarded then return“ the messages are for free.

What do you think of this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0