Trace logging
#1
Can I add a trace logging level and would it be OK to add logging that falls in that category?

I would be especially benefictial for new people (me!) in the future.
Reply
#2
I'm all for it.

Perhaps a dev more comfortable with linux may wish to comment as well?

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
I'm all for it as well
Reply
#4
So be nice and bare with me, this is all new (at least from a tool perspective).. I'm just going to post the patch text below.. I've added a TRACELOG macro that gets compiled out in anything other than debug. There were a few of the logging bits I wasn't overly sure about so I just gave it a stab. Nothing seems broken at least. Smile

What's the preferred method? I see some people post it to sourceforge, but I thought I read somewhere the whole, changed files are easier.

Code:
Index: log.h
===================================================================
--- log.h    (revision 13269)
+++ log.h    (working copy)
@@ -1,26 +1,5 @@
#pragma once

-/*
- *      Copyright (C) 2005-2008 Team XBMC
- *      http://www.xbmc.org
- *
- *  This Program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  This Program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with XBMC; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *  http://www.gnu.org/copyleft/gpl.html
- *
- */
-
#include <stdio.h>

#define LOG_LEVEL_NONE         -1 // nothing at all is logged
@@ -28,17 +7,19 @@
#define LOG_LEVEL_DEBUG         1 // shows all
#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
#define LOG_LEVEL_DEBUG_SAMBA   3 // shows all + freemem on screen + samba debugging
-#define LOG_LEVEL_MAX           LOG_LEVEL_DEBUG_SAMBA
+#define LOG_LEVEL_TRACE         4
+#define LOG_LEVEL_MAX           LOG_LEVEL_TRACE

// ones we use in the code
-#define LOGDEBUG   0
-#define LOGINFO    1
-#define LOGNOTICE  2
-#define LOGWARNING 3
-#define LOGERROR   4
-#define LOGSEVERE  5
-#define LOGFATAL   6
-#define LOGNONE    7
+#define LOGTRACE   0
+#define LOGDEBUG   1
+#define LOGINFO    2
+#define LOGNOTICE  3
+#define LOGWARNING 4
+#define LOGERROR   5
+#define LOGSEVERE  6
+#define LOGFATAL   7
+#define LOGNONE    8

#ifdef __GNUC__
#define ATTRIB_LOG_FORMAT __attribute__((format(printf,2,3)))
@@ -59,6 +40,12 @@
   static void DebugLogMemory();
};

+#ifdef _DEBUG
+  #define TRACELOG() CLog::Log(LOGTRACE, "%s(%d)", __PRETTY_FUNCTION__, __LINE__);
+#else
+  #define TRACELOG()
+#endif
+
// GL Error checking macro
// this function is useful for tracking down GL errors, which otherwise
// just result in undefined behavior and can be difficult to track down.
Index: log.cpp
===================================================================
--- log.cpp    (revision 13269)
+++ log.cpp    (working copy)
@@ -1,43 +1,3 @@
-/*
- *      Copyright (C) 2005-2008 Team XBMC
- *      http://www.xbmc.org
- *
- *  This Program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  This Program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with XBMC; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *  http://www.gnu.org/copyleft/gpl.html
- *
- */
-/*
- *      Copyright (C) 2005-2008 Team XBMC
- *      http://www.xbmc.org
- *
- *  This Program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  This Program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with XBMC; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *  http://www.gnu.org/copyleft/gpl.html
- *
- */

#include "stdafx.h"
#include "log.h"
@@ -54,8 +14,8 @@

static CCriticalSection critSec;

-static char levelNames[][8] =
-{"DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "SEVERE", "FATAL", "NONE"};
+static char levelNames[][9] =
+{"TRACE", "DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "SEVERE", "FATAL", "NONE"};


CLog::CLog()
Reply
#5
My apologies. I was trying to figure out why the patch was so big and it didn't occur to me until after I posted that some GPL header stuff was added inbetween the last time I got the code and when I created a new working copy a bit ago. So when I copied my files wholesale from the older checkout into the new checkout it wiped that stuff out. This should be a _MUCH_ better patch.

Code:
Index: log.h
===================================================================
--- log.h    (revision 13269)
+++ log.h    (working copy)
@@ -28,17 +28,19 @@
#define LOG_LEVEL_DEBUG         1 // shows all
#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
#define LOG_LEVEL_DEBUG_SAMBA   3 // shows all + freemem on screen + samba debugging
-#define LOG_LEVEL_MAX           LOG_LEVEL_DEBUG_SAMBA
+#define LOG_LEVEL_TRACE         4
+#define LOG_LEVEL_MAX           LOG_LEVEL_TRACE

// ones we use in the code
-#define LOGDEBUG   0
-#define LOGINFO    1
-#define LOGNOTICE  2
-#define LOGWARNING 3
-#define LOGERROR   4
-#define LOGSEVERE  5
-#define LOGFATAL   6
-#define LOGNONE    7
+#define LOGTRACE   0
+#define LOGDEBUG   1
+#define LOGINFO    2
+#define LOGNOTICE  3
+#define LOGWARNING 4
+#define LOGERROR   5
+#define LOGSEVERE  6
+#define LOGFATAL   7
+#define LOGNONE    8

#ifdef __GNUC__
#define ATTRIB_LOG_FORMAT __attribute__((format(printf,2,3)))
@@ -59,6 +61,12 @@
   static void DebugLogMemory();
};

+#ifdef _DEBUG
+  #define TRACELOG() CLog::Log(LOGTRACE, "%s(%d)", __PRETTY_FUNCTION__, __LINE__);
+#else
+  #define TRACELOG()
+#endif
+
// GL Error checking macro
// this function is useful for tracking down GL errors, which otherwise
// just result in undefined behavior and can be difficult to track down.
Index: log.cpp
===================================================================
--- log.cpp    (revision 13269)
+++ log.cpp    (working copy)
@@ -54,8 +54,8 @@

static CCriticalSection critSec;

-static char levelNames[][8] =
-{"DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "SEVERE", "FATAL", "NONE"};
+static char levelNames[][9] =
+{"TRACE", "DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "SEVERE", "FATAL", "NONE"};


CLog::CLog()
Reply
#6
unified diff against the SVN head is the prefered format I believe, see:
http://wiki.xbmc.org/?title=HOW-TO_submit_a_patch
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#7
I think that's what that is. Smile But I could be wrong. Anyone?

I can zip it and put it on sourceforge if that helps...
Reply
#8
The ideal atm is a unified diff as you've done posted to sourceforge to allow tracking. Please don't zip it up unless you absolutely have to due to size restrictions (it'd be pretty damn big though Wink

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
In any event, here it is on sourceforge:

http://sourceforge.net/tracker/index.php...tid=581840
Reply

Logout Mark Read Team Forum Stats Members Help
Trace logging0