Class and method names (or function names) - how do I get them in the log

669 views
Skip to first unread message

Ran Tavory

unread,
Jun 15, 2011, 8:06:23 AM6/15/11
to cocoalu...@googlegroups.com
When using ddlog, the log messages I see in the simulator's console don't contain the class and method names (or for simple c functions, the function name).
Is there a way to get them in?

Here's an example log line produced by DDLogInfo:
(editor is the name of the app)

2011-06-15 14:58:40:715 editor[46298:40b] Deleting file /Users/ran/Library/Application Support/iPhone Simulator/4.3/Applications/8A0A1CA8-52F3-44F2-86C6-8A4BD68E3D6E/Documents/templates/template.cards.july4.usamas_last_words/template.cards.july4.usamas_last_words.customize


What does editor[46298:40b] mean and how do I replace them with something along the lines of ClassName:methodName ?

Thanks!

Ran Tavory

unread,
Jun 15, 2011, 1:18:43 PM6/15/11
to cocoalu...@googlegroups.com
I've looked further into DDLog.h/m and it seems that there's certainly intention in log:level:flag:context:file:function:line:format to add the file name, function and line number but for some reason, the end result is that they are not in my logs.

+ (void)log:(BOOL)synchronous

      level:(int)level

       flag:(int)flag

    context:(int)context

       file:(const char *)file

   function:(const char *)function

       line:(int)line

     format:(NSString *)format, ...


I've also tried adding them explicitly and this worked but of course I don't want to do this on every log statement...

  DDLogInfo(@"%s [Line %d] - Application Home: %@", __PRETTY_FUNCTION__, __LINE__, [self applicationDocumentsDirectory]);

2011-06-15 20:13:30:593 editor[50839:40b] -[AppDelegate logDebugInfo] [Line 133] - Application Home: /Users/ran/Library/Application Support/iPhone Simulator/4.3/Applications/8A0A1CA8-52F3-44F2-86C6-8A4BD68E3D6E/Documents


--
You received this message because you are subscribed to the Google Groups "CocoaLumberjack" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cocoalumberjack/-/BAM_U9JKCCMJ.
To post to this group, send email to cocoalu...@googlegroups.com.
To unsubscribe from this group, send email to cocoalumberja...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cocoalumberjack?hl=en.



--
/Ran

Robbie Hanson

unread,
Jun 18, 2011, 3:48:28 PM6/18/11
to cocoalu...@googlegroups.com
Hi Ran,

All of what you want is possible and more. Take a look at the wiki:


Specifically the page on custom formatters:


It's really easy. I think you'll like it.

-Robbie Hanson
Sent from my iPhone

Ran Tavory

unread,
Jun 19, 2011, 1:24:09 AM6/19/11
to cocoalu...@googlegroups.com
got it, thanks
--
/Ran

Tapan Nathvani

unread,
Aug 5, 2013, 6:37:59 AM8/5/13
to cocoalu...@googlegroups.com, ran...@gmail.com
Hello ray, can you please tell me how you solved it...

Ashish Gadre

unread,
Nov 4, 2014, 8:06:35 PM11/4/14
to cocoalu...@googlegroups.com, ran...@gmail.com
I am trying to get the logging of File and function names printed as well. What do I need to do to get this working. The code.google links are dead.

-Ashish

Sasidhar Lakku

unread,
Jan 20, 2017, 11:31:08 AM1/20/17
to CocoaLumberjack, ran...@gmail.com

.Hello Ashish,

 Are you able to fix this issue? Able to log file, function names?

- Sasi


On Wednesday, November 5, 2014 at 6:36:35 AM UTC+5:30, A Gadre wrote:
I am trying to get the logging of File and function names printed as well. What do I need to do to get this working. The code.google links are dead.

-Ashish

On Monday, August 5, 2013 3:37:59 AM UTC-7, Tapan Nathvani wrote:
Hello ray, can you please tell me how you solved it...

On Sunday, 19 June 2011 10:54:09 UTC+5:30, Ran Tavory wrote:
2ot it, thanks
Reply all
Reply to author
Forward
0 new messages