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

Pass log context number to CocoaLumberjack if defined #315

Merged
merged 1 commit into from Dec 29, 2013
Merged

Pass log context number to CocoaLumberjack if defined #315

merged 1 commit into from Dec 29, 2013

Conversation

fgarcia
Copy link
Contributor

@fgarcia fgarcia commented Nov 21, 2012

Since MagicalRecord already has some reference to CocoaLumberjack, I decided to add an optional context number.

If CocoaLumberjack is pressent and the user defines the macro MR_LOG_CONTEXT with a number, this will be used as the logging context id. That way the user can reformat/filter/control the logs coming from MagicalRecord

@guillaume-michel
Copy link

this would be a nice feature.

@casademora
Copy link
Member

So is the Log Context some indication of a log level specific to MagicalRecord?

@guillaume-michel
Copy link

yes. The context can be used to identify logs coming from Magical Record as opposed to log coming from somewhere else.

@fgarcia
Copy link
Contributor Author

fgarcia commented Dec 13, 2012

I guess the answer to your question is: somehow YES, but not what it seems. I should explain the current status and the effect of the change because you mention "log level" in a way that might lead to some confusion.

MagicalRecord uses only one log level. Before and after this patch, if CocoaLumberjack is available, MagicalRecord will use the VERBOSE level, the most "noisy" of the default log levels (verbose, debug, warn, error). I have not changed the log level. Therefore after this patch will send logs with the same LEVEL

However, CocoaLumberjack users can write their own filters and formatters. Every log message has a CONTEXT number. That way the formater or filter can identify the module/library sending that log. It does not change the log level, but allows the user to identify the origin of the log. Currently MagicalRecord is using the default context marker and that way it is not possible to identify the source of MagicalRecord logs.

@casademora
Copy link
Member

So, basically, the gist of this request is to allow for Cocoalumberjack to be able to filter out MagicalRecord logging for an app when the app includes MagicalRecord? Even though everything will eventually be verbose (which I think is ok for a framework/library...

On Dec 13, 2012, at 9:42 AM, Francisco Garcia Rodriguez notifications@github.com wrote:

I guess the answer to your question is: somehow YES, but not what it seems. I should explain the current status and the effect of the change because you mention "log level" in a way that might lead to some confusion.

MagicalRecord uses only one log level. Before and after this patch, if CocoaLumberjack is available, MagicalRecord will use the VERBOSE level, the most "noisy" of the default log levels (verbose, debug, warn, error). I have not changed the log level. Therefore after this patch will send logs with the same LEVEL

However, CocoaLumberjack users can write their own filters and formatters. Every log message has a CONTEXT number. That way the formater or filter can identify the module/library sending that log. It does not change the log level, but allows the user to identify the origin of the log. Currently MagicalRecord is using the default context marker and that way it is not possible to identify the source of MagicalRecord logs.


Reply to this email directly or view it on GitHub.

@fgarcia
Copy link
Contributor Author

fgarcia commented Dec 13, 2012

just as document for the future:

I also thought about a second macro to define the default log level of MagicalRecord. However I rejected using that second macro because:

  1. I wanted to avoid adding more complexity
  2. My personal preference is that if a third party library mix its logs with my programs, it should only do so only with a very verbose level. If the user really wants a different log level, it is still possible to upgrade this level using a custom formater that looks for the MagicalRecord context

@fgarcia
Copy link
Contributor Author

fgarcia commented Dec 13, 2012

@casademora Yes, with my pull request Cocoalumberjack users will be able to filter/reformat MagicalRecord logs, even if they still are always verbose

next time I will write better pull request descriptions. Lesson learned!

@casademora
Copy link
Member

Oh, the request is fine, its my and the team's lack of extra time that is making things slower than desired :(
We're trying to regroup for the coming year. Thanks for the request, if we don't pull it here, we'll most likely add it to the next release!

Thanks!

On Dec 13, 2012, at 9:53 AM, Francisco Garcia Rodriguez notifications@github.com wrote:

@casademora Yes, with my pull request Cocoalumberjack users will be able to filter/reformat MagicalRecord logs, even if they still are always verbose

next time I will write better pull requests. Lesson learned!


Reply to this email directly or view it on GitHub.

@fgarcia
Copy link
Contributor Author

fgarcia commented Dec 13, 2012

Thanks! Just keep the great work. I am actually more concerned with other people not having a 2.0.9 release. There is a bug with 2.0.8 where saving a context does not always work but was solved immediately after on commit cfccd40. I guess that is upsetting people using only the master branch or cocoapods. I was surprised to see that it is taking so long to have a release with that bugfix. It is a wild world of annoying users out there. Please, just keep doing such a great library.

@tonyarnold
Copy link
Contributor

Is this still a relevant change for users of CocoaLumberjack?

@ghost ghost assigned tonyarnold Apr 21, 2013
@fgarcia
Copy link
Contributor Author

fgarcia commented Apr 21, 2013

yes, the current logging macro MRLog as defined now, calls CocoaLumberjack without any specific context number.

Without that number, users customizing their logs output cannot identify which messages are sent by MagicalRecord. As mentioned above, my proposal still logs everything with the Verbose log level, but with a context number alone, it is possible to identify which logs are generated by MR

MR does not generate logs with different levels, so it does not make sense implementing a more complex solution.

@tonyarnold
Copy link
Contributor

I know Saul has been toying with this in the experimental branch — I’ll leave this in his capable hands (I don’t use CocoaLumberjack at the moment).

@ghost ghost assigned casademora Aug 16, 2013
tonyarnold added a commit that referenced this pull request Dec 29, 2013
Pass logging context number to CocoaLumberjack if defined
@tonyarnold tonyarnold merged commit 05d34cb into magicalpanda:develop Dec 29, 2013
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