Skip to content

Add getLoggerByQuotation and deprecate getCurrentLogger #7

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

Merged
merged 3 commits into from
Oct 3, 2019

Conversation

TheAngryByrd
Copy link
Owner

@TheAngryByrd TheAngryByrd commented Oct 3, 2019

Proposed Changes

Add getLoggerByQuotation and deprecate getCurrentLogger.

getCurrentLogger uses the StackFrame and skip to try to figure out where we are in our codebase, however it can give really inconsistent results and lead programmers astray, even thought it seems like the most obvious path.

To alleviate the need to handroll your own fully qualified namespace strings I've added getLoggerByQuotation which allows you to write code like

namespace Bar 

module Foo = 
  let rec logger = LogProvider.getLoggerByQuotation <@ logger @>

Which will create a logger with the Bar.Foo path.

Also adds getLoggerByFunc which is useful only within functions.

    let hello name  =
        let logger2 = LogProvider.getLoggerByFunc ()
        // Starts the log out as an Informational log
        logger2.info(...)

Will result in SomeLib.Say.hello. This cannot protect against inlining but this is no worse than the StackFrame method.

Types of changes

What types of changes does your code introduce to FsLibLog?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Build and tests pass locally
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@TheAngryByrd TheAngryByrd merged commit e9b1b53 into master Oct 3, 2019
TheAngryByrd pushed a commit that referenced this pull request Oct 3, 2019
* FEATURE: Adds to LogProvider two new methods `getLoggerByQuotation` and `getLoggerByFunc`. Also deprecates `getCurrentLogger`. (#7)
@TheAngryByrd TheAngryByrd deleted the getLoggerByQuotation branch August 18, 2020 14:56
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

Successfully merging this pull request may close these issues.

1 participant