Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support typed log labels #8

Open
larskuhtz opened this issue Feb 10, 2015 · 5 comments
Open

Support typed log labels #8

larskuhtz opened this issue Feb 10, 2015 · 5 comments

Comments

@larskuhtz
Copy link
Member

No description provided.

@gregwebs
Copy link

We aren't using these right? What is the purpose supposed to be?

@larskuhtz
Copy link
Member Author

We use them in several places. The purpose is to add labels to log-messages.

The original motivation was to add scope to log messages. For example services often have several subcomponents and it is helpful to see from where a log comes:

httpClientComponent = withLabel ("component", "http-client") $ do...
awsClient httpClient = withLabel ("component", "aws-client") $ do {- may use httpClient -}...
adminInternface = withLabel ("service-interface", "admin") $ do ...
publicInterface = withLabel ("service-interface", "public") $ do....

It also helps with building services in a modular way, since the code that generates log messages them doesn't need to know about it's context.

Consumers, for example the backend, can use this labels to pattern match and apply special processing.

In the past I had to write a log-analyzer that aggregated all the logs from all our services. Those labels where extremely useful. The alternative would have been to match with regex into the text messages.

It's also helpful for debugging:

someWeirdFunction = withLevel Debug $ withLabel ("function", "someWeirdFunction") $ ....
  where
    crazy = withLabel ("function", "crazy") $ ...

@larskuhtz
Copy link
Member Author

Right now the labels are not typed -- so users should agree on certain labels. I consider to make the type of the labels (either the key, or the value, or both, or the complete label type) a type parameter (that would be instantiated to (Text,Text) in the high-level default API).

@larskuhtz
Copy link
Member Author

An alternative approach would be to have library users implement labels them self as part of the log message type. But often (for simple projects) it is convenient to just use Text as message type and get labels out of the box.

Also it's nice to have direct support for the labels in MonadLog which wouldn't be possible if labels would be part of the log messages without rolling your own monad on top of MonadLog.

@gregwebs
Copy link

ok, that makes sense. Log sections (component labels) are a standard logging feature.

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

No branches or pull requests

2 participants