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

Lints and automatic scope handling with syntax extension #4

Open
james-darkfox opened this Issue Jul 17, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@james-darkfox
Owner

james-darkfox commented Jul 17, 2015

The biggest problem with scoped_log is 'where' to start scoped logs. A syntax extension could be used to either automate the handling all together via #[attributes] or provide lints to show where scopes may be undesired.

#[scoped(Debug)]
struct Server;

impl Server {
    pub fn method() { <injected-macro-usage> ..; Self::private_method() }
    fn private_method() { info!("Bar") }
}

Resulting in:

INFO:main: Server: Bar
  • Lints
    • MUST NOT set scopes to self in private methods.
    • MUST NOT set the same scope multiple times in the same control flow.
    • Scopes MUST NOT outlive the object their document
  • Attributes
    • Handle the implied positioning of scopes.
    • Decide if we want the Display or Debug format handlers.
    • Custom display handlers?
  • Use an immutable reference to the object to call the respective fmt when displaying the object.
    • Able to mutate with the object that it documents. I.e. An identifier that is displayed may be a mutable value on the object.
    • Scopes can't be sent cross threads
    • Can this be implemented without unsafe { .. } ?
    • Automatic reference counter wrapping? Would this lock?

@james-darkfox james-darkfox added this to the 0.2.0 milestone Jul 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment