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

Should we provide an easier way to let controller accessing a logger #146

Closed
cescoffier opened this Issue Apr 12, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@cescoffier
Member

cescoffier commented Apr 12, 2014

No description provided.

@cescoffier cescoffier added this to the 0.5 milestone Apr 12, 2014

@barjo

This comment has been minimized.

Show comment
Hide comment
@barjo

barjo Apr 15, 2014

Member

Should we add a logger() method in the AbstractController ?

Member

barjo commented Apr 15, 2014

Should we add a logger() method in the AbstractController ?

@cescoffier

This comment has been minimized.

Show comment
Hide comment
@cescoffier

cescoffier Apr 15, 2014

Member

Yes, that would be the idea. However, I'm worried about the access time:

public Logger logger() { 
    return LoggerFactory.getLogger(this.getClass());
}

So something like is probably better:

private Logger logger;
public Logger logger() { 
    if (logger == null) {
        logger = LoggerFactory.getLogger(this.getClass());
    }
    return logger;
}
Member

cescoffier commented Apr 15, 2014

Yes, that would be the idea. However, I'm worried about the access time:

public Logger logger() { 
    return LoggerFactory.getLogger(this.getClass());
}

So something like is probably better:

private Logger logger;
public Logger logger() { 
    if (logger == null) {
        logger = LoggerFactory.getLogger(this.getClass());
    }
    return logger;
}
@barjo

This comment has been minimized.

Show comment
Hide comment
@barjo

barjo Apr 15, 2014

Member

+1

Member

barjo commented Apr 15, 2014

+1

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