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

Rules ordering and filtering #274

Closed
TheAngryByrd opened this issue Nov 29, 2017 · 2 comments
Closed

Rules ordering and filtering #274

TheAngryByrd opened this issue Nov 29, 2017 · 2 comments
Milestone

Comments

@TheAngryByrd
Copy link

I seem to be misunderstanding how rules and ordering work

From this comment:


/// Rules compose to the maximal filter. I.e. if you have one rule for your
/// target that specifies all Message-s must be of Debug level, and then another
/// filter that specifies they have to be of Info level, then the rule of Info
/// will win, and all Debug-level messages will be filtered from the stream.

I'd expect this test to pass:

    yield ftestCase "Rule Ordering" <| fun _ ->

        let out = Fac.textWriter ()
        let rules = [
            Rule.empty |> Rule.setHieraString "Marten" |> Rule.setTarget "console" |> Rule.setLevel Info
            Rule.empty |> Rule.setTarget "console" |> Rule.setLevel Verbose
        ]

        let targets = [
            Target.confTarget "console" (TextWriter.create <| TextWriter.TextWriterConf.create(out, out))
        ]
        let logary = confLogary "tests" |> withRules rules |> withTargets targets |> validate |> runLogary |> run

        let get = Registry.getLogger logary.registry >> run
        let no1 = pnp "Marten" |> get
        Expect.equal no1.level Info "Marten should be Info"
        let no2 = pnp "Anything.Else" |> get
        Expect.equal no2.level Verbose "Anything.Else should be Verbose"

But it's failing with

Marten should be Info. Actual value was Verbose but had expected it to be Info.

What am I doing wrong?

@lust4life
Copy link
Contributor

i think, maybe there is a misleading here, the implementation now actually use the minimal strategy.

in pr #219 , we use strict strategy , and in there, there is no loglevel on logger, loglevel belongs to message and rule belongs to target. a logger just send msg to processing pipeline (can filter msg through its level) , after pipeline ,we know the msg will go to which targets, then the targets will filter them depend on its rules.

@lust4life lust4life added this to the v5.0 milestone Dec 5, 2017
@haf
Copy link
Member

haf commented Apr 8, 2018

https://github.com/logary/logary/blob/master/src/Logary/Rule.fs#L98 — current + what @lust4life said

@haf haf closed this as completed Apr 8, 2018
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

3 participants