|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic Page: 1 2 »» |
Last Thread Next Thread ![]() |
| Using XML Technologies For Enhancing Log Files |
|
![]() Drew_Benton GDNet+ Member since: 7/29/2004 From: Katy, TX, United States |
||||
|
|
||||
| Beautiful. Just Beautiful. Thanks for the hard work guys! I will have to test this stuff out when I get my dev computer up and running again. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Interesting, tho it should be noted that using XML+XSLT+javascript for logging is not new. GLIntercept has been doing it for some time in it's OpenGL logs. Link: http://glintercept.nutty.org/Demo02/gliInterceptLog.xml |
||||
|
||||
![]() _DarkWIng_ Member since: 1/11/2001 From: Duplje, Slovenia |
||||
|
|
||||
| Wow, this is great. Looks like my logging system needs an update. Is there something simmilar to __NAMESPACE__, __FILE__, __FUNCTION__ or __LINE__ avabile in C# (2.0) or do I have to use System.Diagnostics.Trace? You should never let your fears become the boundaries of your dreams. |
||||
|
||||
![]() jollyjeffers Moderator - DirectX and XNA Member since: 3/16/2000 From: London, United Kingdom |
||||
|
|
||||
Quote: Cheers ![]() Quote: Very true, but it is a mature technology now... as I see it, it's done it's time as the "look at me! I'm a cool new thing you should use" and has refined itself into a solid set of technologies. More importantly, as I mentioned in the article, you have a lot of choices for the tools to create/view the results in... Quote: I don't use C# myself, so I'm not sure... If you didn't have all the information available for free from the runtime/compiler you could, with a bit of effort, probably add this information in by defining some const/static strings? hth Jack Jack Hoxley [ Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ] |
||||
|
||||
![]() rick_appleton Member since: 8/29/2002 From: Delft, Netherlands |
||||
|
|
||||
| A very, very good article. Clear, informative, interesting, useful. I could go on. I've messed with using html/javascript for my log files, but I've never taken it to this level. I'm sure that now I will. |
||||
|
||||
![]() evolutional Moderator - Alternative Game Libraries Member since: 1/25/2002 From: Leeds, United Kingdom |
||||
|
|
||||
| I've implemented this into my games since I saw what Jack's implementation of the original idea could do. I must admit that it's helped me out a lot with debugging. There's nothing worse than having to trawl through a log file looking for errors or warnings, it makes it so much easier to be able to colour-code the viewing of the log file and have the ability to see all errors or even ones from just a specific system. |
||||
|
||||
![]() rick_appleton Member since: 8/29/2002 From: Delft, Netherlands |
||||
|
|
||||
| I've been messing around with the code for a few hours, and I've already come up with an improvement I'd like to share. In the .xsl file, the if statements compare the $eventType (and the $nameSpace, and $specificFile) with a literal string to see if that type of event needs to be filtered out. If the literal comparison is changed to 'contains($eventType,'Warning')' it becomes possible to view any combination of types. The types can then be toggled from the html/javascript to allow an even greater degree of customization. The same obviously goes for the namespace and specific file. I hope someone finds this useful. |
||||
|
||||
![]() jfclavette Member since: 2/12/2003 From: Sherbrooke, Canada |
||||
|
|
||||
Oh God. I just finished my XML + XSLT like, 5 seconds before I saw the article. Great work, some of your features are very interesting, guess I'll get back and rewrite some parts of it ![]() |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Nice article. There is but one thing I'd like to suggest as an improvement and that's to possibly use an XML library to generate your xml documents with. Perhaps something like TinyXML? Or perhaps add a small interface that will XML encode your values? The reason I say that is because: outFile " "; may not result in well formed xml (eg. what if someString contained the text "X < |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Sorry (I didn't have well formed forum code ;)). Nice article. There is but one thing I'd like to suggest as an improvement and that's to possibly use an XML library to generate your xml documents with. Perhaps something like TinyXML? Or perhaps add a small interface that will XML encode your values? The reason I say that is because: outFile " "; may not result in well formed xml. Other than that, this is spot on :) |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| AH! I give up. Just watch for badly formed XML :D |
||||
|
||||
![]() DrEvil Member since: 7/13/2003 From: Los Angeles, CA, United States |
||||
|
|
||||
| Thanks guys, great article. edit: I could be wrong, but wouldn't the WriteLogEntry function be better off using const char * as the type for the __NAMESPACE__, __FILE__, __FUNCTION__, __LINE__ parameters? Else there is a lot of implicit std::string conversions going on that could impact performance. [Edited by - DrEvil on June 13, 2005 10:24:32 AM] |
||||
|
||||
![]() jollyjeffers Moderator - DirectX and XNA Member since: 3/16/2000 From: London, United Kingdom |
||||
|
|
||||
Quote: you need to use the escape codes: < or > to get what you want:outFile << " "; Either way, I get what you're saying... I did cut a corner with that part of the code, but it wasn't really the main focus of the article. I had considered TinyXML, but it was a bit too much for what I personally needed - it's an unsafe assumption I know, but in my logfile output invalid characters aren't a problem ![]() Quote: Glad you liked it ![]() Jack Jack Hoxley [ Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ] |
||||
|
||||
![]() CTar Member since: 3/20/2005 From: Farum, Denmark |
||||
|
|
||||
| Very nice article are there any sourcecode available? I'm curios about how you implemented the __NAMESPACE__, just had a "const char* __NAMESPACE__" or "const std::string __NAMESPACE__" variable in each namespace with the name of the namespace? |
||||
|
||||
![]() jollyjeffers Moderator - DirectX and XNA Member since: 3/16/2000 From: London, United Kingdom |
||||
|
|
||||
Quote: The source code to the C++ part of things isn't included (iirc), but the rest is all included in a zip file here __NAMESPACE__ is a bit of a hack sadly ( ), off the top of my head, it's just a #define __NAMESPACE__ "something" at the top of each/every file.Jack Jack Hoxley [ Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ] |
||||
|
||||
![]() mfawcett Member since: 1/17/2003 From: Chantilly, VA, United States |
||||
|
|
||||
Quote: I haven't read the article, but perhaps you could do something like this? #define NAMESPACE(n) namespace n { const char *scope_ = #n; } namespace n #define __NAMESPACE__ scope_ NAMESPACE(one) { NAMESPACE(two) { void printnamespace(void) { std::cout << __NAMESPACE__ << std::endl; } } } Unfortunately, that would only print "two", not "one::two". If any enterprising individuals want to make some modifications to support that, I think it would be pretty cool. Obviously you'd want to make it a little safer and use less common names than I used in the short example. |
||||
|
||||
![]() evolutional Moderator - Alternative Game Libraries Member since: 1/25/2002 From: Leeds, United Kingdom |
||||
|
|
||||
| If anyone really needs some code for this, I can whizz you an example from my upcoming 4E4 entry. It's a pretty simplified version of what's happening here, but is similar in operation. |
||||
|
||||
![]() CTar Member since: 3/20/2005 From: Farum, Denmark |
||||
|
|
||||
Quote: Well I got this to work for me: const std::string __NAMESPACE__ = ""; #define NAMESPACE(n)\ namespace n \ {\ const std::string _INTERNAL__SCOPE_STR_TEMP = __NAMESPACE__;\ const std::string __NAMESPACE__ = ((_INTERNAL__SCOPE_STR_TEMP+"::")+#n);\ }\ namespace n\ EDIT: Is there a way to make \ in the sourcecode? (FIXED) |
||||
|
||||
![]() jollyjeffers Moderator - DirectX and XNA Member since: 3/16/2000 From: London, United Kingdom |
||||
|
|
||||
Good modifications for the __NAMESPACE__ thing! thanks for posting them (++rating)... think I might implement them in my own code. Probably a bit too late to update the article now thought ![]() Cheers, Jack Jack Hoxley [ Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ] |
||||
|
||||
![]() CipherCraft Member since: 11/30/2004 From: Amsterdam, Netherlands |
||||
|
|
||||
| Hi, I've tried this approach before and found it to be very informing but for one situation: a program crash. When that happens your log will be incomplete and will contain malformed XML. And since it's a very strict language, many (good) XML viewers will be unable/unwilling to show you the contents. This again means that tracking down the reason your app crashed must begin with fixing your log. I'm curious, considering the high level of content in your article, if you have found a solution for that. cu, CipherCraft |
||||
|
||||
![]() Marcus Speight Member since: 6/18/2003 From: Burton upon Trent, United Kingdom |
||||
|
|
||||
| To stop a malformed xml file. Just add the closing tag after each LogEvent. But remember to get the file position before the closing tag, so when you add the next event go to the remembered file position write the new event, remember the position and add the closing tag. ofs.seekp(file_position); // output log event file_position = ofs.tellp(); ofs << "</RunTimeLog>" << std::endl; ofs.flush(); Marcus EDIT: put it in source |
||||
|
||||
![]() evolutional Moderator - Alternative Game Libraries Member since: 1/25/2002 From: Leeds, United Kingdom |
||||
|
|
||||
Quote: More than likely, the malformed Xml will be due to an unterminated xml tag and not as a result of a crash during log writing (could happen though it's unlikely). In this scenario, I've found it best to have a log shutdown routine that is called when your application catches a fatal exception - the shutdown routine finalises the log file ready for viewing. It's worth noting that you can open the logfile in a text editor to view the last sequence of entries to allow you to see where the crash happened, even if the logfile isn't termiated properly. |
||||
|
||||
![]() Drag0n Member since: 10/9/2001 From: Ulm, Germany |
||||
|
|
||||
| Hi, I think this is a great article, even though I haven't read it completely yet. One thing I noticed though is that your "id" attributes don't conform to the XML standard. In section 3.3.1 of the standard it reads: Quote: And this name production is found in section 2.3: Quote: Which means that the ID attribute needs to start with either a letter, an underscore, or a colon. Not a big deal, but somehow I felt the need to point that out... ;) Cheers, Drag0n |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| I too am interested in xml for logging purposes. The only reason I hesitated was this: Microsoft has been granted United States patent 6,687,897 for "XML script automation." "While the XML standard itself is royalty free, nothing precludes a company from seeking patent protection for a specific software implementation that incorporates elements of XML. This does not, in any way, change the royalty-free nature of the XML standard itself." The way the last paragraph reads to me is "Using xml is fine in your app - until Microsoft wants to play ball too. Then they will use the bat on you." I just program. I'm no lawyer. Can anyone can clear this mess up? |
||||
|
||||
|
Page: 1 2 »» All times are ET (US) ![]() |
Last Thread Next Thread ![]() |
|