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

Allow disabling of specific levels per-logger. #204

Merged

Conversation

matt-holden
Copy link
Contributor

My team's usage of LumberJack had the following setup:

  • four loggers, DDTTYLogger and DDFileLogger, a crash logger, and an
    analytics logger
  • globally-defined ddLogLevel = LOG_LEVEL_DEBUG

Our file logger is added with LOG_LEVEL_INFO.
Our TTY logger is added with LOG_LEVEL_DEBUG.

We use "INFO" events HEAVILY, as they are placed in the file logger and
crash logger to help us know everything that happened leading up to a
bug.

As a requirement, The file logger CANNOT log DEBUG events.

At the same time, because we have such a high volume of INFO events, it
is challenging to see any of the DEBUG events in the TTY logger.

We need to be configure our DDTTYLogger to at the DEBUG level, but omit INFO events.

Essentially: [DDLog addLogger:ttyLogger withLogLevel:(LOG_LEVEL_DEBUG & (~LOG_FLAG_INFO)];

However, this isn't possible in the current implementation of
+[DDLogger lt_log]

When iterating through registered loggers, lt_log:
performs the check, "if (logMessage->logFlag > loggerNode.logLevel) continue;"

Because our TTY logger's highest-set bit is LOG_FLAG_DEBUG, all info
events are processed, even though we've unset the LOG_FLAG_INFO event.

My proposed change configures lt_log: to examine whether a DDLogMessage's
specific LOG_FLAG_..* is set in loggerNode->logLevel.

My team's usage of LumberJack had the following setup:

- four loggers, `DDTTYLogger` and `DDFileLogger,` a crash logger, and an
  analytics logger
- globally-defined ddLogLevel = `LOG_LEVEL_DEBUG`

Our file logger is added with `LOG_LEVEL_INFO.`
Our TTY logger is added with `LOG_LEVEL_DEBUG.`

We use "INFO" events HEAVILY, as they are placed in the file logger and
crash logger to help us know everything that happened leading up to a
bug.

As a requirement, The file logger CANNOT log DEBUG events.

At the same time, because we have such a high volume of INFO events, it
is challenging to see any of the `DEBUG` events in the TTY logger.

We need to be configure our `DDTTYLogger` to at the DEBUG level, but omit `INFO` events.

Essentially: `[DDLog addLogger:ttyLogger withLogLevel:(LOG_LEVEL_DEBUG & (~LOG_FLAG_INFO)];`

However, this isn't possible in the current implementation of
`+[DDLogger lt_log]`

When iterating through registered loggers, `lt_log:`
performs the check, "if (logMessage->logFlag > loggerNode.logLevel) continue;"

Because our TTY logger's highest-set bit is `LOG_FLAG_DEBUG`, all info
events are processed, even though we've unset the `LOG_FLAG_INFO` event.

My proposed change configures `lt_log:` to examine whether a `DDLogMessage`'s
specific `LOG_FLAG_..*` is set in `loggerNode->logLevel`.
@rivera-ernesto
Copy link
Member

Related to #203.

Looks good to me.
Also we're getting to a point where DDlog.h/m files need a cleanup.

@matt-holden
Copy link
Contributor Author

Fantastic.

I'm really loving working with this framework. I think I'll have to dig deeper into the codebase...

rivera-ernesto pushed a commit that referenced this pull request Jan 15, 2014
Allow disabling of specific levels per-logger.
@rivera-ernesto rivera-ernesto merged commit 6f6887c into CocoaLumberjack:master Jan 15, 2014
@matt-holden
Copy link
Contributor Author

Thanks for pulling this in!

Do you happen to know when you plan to create the next .podspec?

@matt-holden matt-holden deleted the per-logger-bitmasks branch January 15, 2014 06:02
@rivera-ernesto
Copy link
Member

Should be soon, but in the mean time you can test it with the :head option.

@erlichmen
Copy link

@matt-holden thanks for the patch this fixes the need for a custom formatter that we needed to assign per logger.
BTW how do you setup the crash logger?

@rivera-ernesto
Copy link
Member

In the case of Crashlytics there is already a logger available.

@bpoplauschi
Copy link
Member

@matt-holden the new version (1.8.0) of Lumberjack is available.

@matt-holden
Copy link
Contributor Author

Awesome!

Sent from my iPhone

On Jan 27, 2014, at 1:44 AM, Bogdan Poplauschi notifications@github.com wrote:

@matt-holden the new version (1.8.0) of Lumberjack is available.


Reply to this email directly or view it on GitHub.

@bpoplauschi bpoplauschi added this to the 1.8.0 milestone Feb 18, 2014
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.

None yet

4 participants