|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Using an RTF Log File |
|
![]() SnprBoB86 Member since: 5/29/2001 |
||||
|
|
||||
| cool stuff but why not just use rtf syntax directly in the log strings instead of using the [tag] style and string replacements? -SniperBoB- |
||||
|
||||
![]() Indeterminatus Member since: 4/2/2000 From: Schärding, Austria |
||||
|
|
||||
| I guess that's because using the [tag] style makes it much more comfortable for the programmer than "hardcoding" rtf syntax. If you really want to do that (use native rtf syntax without string replacements done by your logging module), you wouldn't need a special rtf logger, because that's what you could do by any other "plain-text-logger" as well... Indeterminatus --si tacuisses, philosophus mansisses-- |
||||
|
||||
![]() Phlegmatic Weasel Member since: 12/1/2003 |
||||
|
|
||||
| Very nice article, but it left me wondering: If you are using tags any way, why not use HTML? I mean, I see your argument about not having to bother with closing tags and the potentially extensive footer, but if you have to write a footer any way, and you use tag-looking things, then doesn't it sort of defeat the purpose? Phlegmatic Weasel |
||||
|
||||
![]() afterburn Member since: 5/30/2000 From: USA |
||||
|
|
||||
| Personally I like W3C as a file format for logs. I can use almost anything to parse the file into a database format in a few lines of code. And with a cheat use MS - "Log Parser 2.1" from the windows 2k3 ResKit to put directly into MS-SQL. Very handy utility. But I use it for alot of things other than that as it can Event Logs, W3C even file system for source of data. Using an SQL like language. Whats the most handy thing about it? Well that would be Reverse_Dns() function, to resolve your IP's to names. Just my 2 cents. But nicely written article. -- What are you nutz? I have nothing to say to your unevolved little brain. The more I say gives you more weapons to ask stupid questions. |
||||
|
||||
![]() afterburn Member since: 5/30/2000 From: USA |
||||
|
|
||||
quote: At that point why not just use a W3C compilant XML Dom parser and write XML instead .... can translate directly to any Web format for a browser to view. And you still do not have to deal with closing tags as the Dom Parser would handle the details with creating the element or attribute. |
||||
|
||||
![]() Ravyne Member since: 2/26/2007 From: Kirkland, WA, United States |
||||
|
|
||||
| Great article. I've recently created something similar mayself. My system uses HTML, well, actually it just outputs and I've created Macros/functions providing HTML formatting. I've been looking into info on RTF formating so that information will be very helpful. The thing I like about HTML, is that its very easy to make macros for everything, I have everything from color formating to bulleted lists to tables if I find it necesary, although its admittedly overkill for most logging purposes. What I do like about my system is that it supports multiple output documents, and its possible using a header template to place a menu linking each document in each file, which makes browsing between things and organization a breeze. For example I might have one file dedicated to video errors, another to sound, and a third to file I/O. Come to think of it, and not to jack your tutorial/thread, if anyone is interested to see it I'd be glad to clean it up and post it with an article. Ravyne, NYN Interactive Entertainment [My Site][My School][My Group] |
||||
|
||||
![]() coldacid Member since: 6/4/2001 From: Pickering, Canada |
||||
|
|
||||
| I think that it would have been better to have written all the code to avoid anything platform-specific. Now, if I want to use this, I'll have to write it (for the most part) from scratch to use standard C++ library stuff like iostreams. It's not too hard to write code that doesn't lock people into Windows, and it's better not to, since there are many programs off of Windows that can deal with RTF files. |
||||
|
||||
![]() jollyjeffers Moderator - DirectX and XNA Member since: 3/16/2000 From: London, United Kingdom |
||||
|
|
||||
| i like the idea/code, very nice. However, a better design to replace the [tag] syntax with any given output method would be even cooler. E.g - replace tags with HTML. For our project I opted to go for the HTML output - makes it very easy to view updates using MSIE (just hit F5 each time you run the game...) just a thought, Jack |
||||
|
||||
![]() cow_in_the_well GDNet+ Member since: 4/8/2000 From: Sydney, Australia |
||||
|
|
||||
quote: why not just use C style fopen/fwrite/fclose? It is a trivial conversion (ie. just replace HANDLE with a FILE*, use fopen instead of CreateFile, fclose instead of CloseHandle, etc). I have done this, since I got hold of Eam's code way before this article ever came out -_^. - Thomas |
||||
|
||||
![]() nosfy Member since: 3/17/2001 From: Montreal, Canada |
||||
|
|
||||
| Wouldn't it be better to use an xml file to log and show it using a css file or even better an xsl? That way you do not encode the way the data should be displayed.. it's all in the css or xsl file. My 2 cents.. -nosfy Lead programmer Creation Objet Inc. |
||||
|
||||
![]() keen Member since: 3/25/2000 From: Goteborg, Sweden |
||||
|
|
||||
| I'd go for ansi colors, that way you can tail -f /path/to/logfile and get output with colors without using a special browser and updates immediatley without the hassle of "Refresh" or opening the document again. If you want the output in plaintext/whatever format you like after that it would be easy to write a converter. [edited by - keen on April 16, 2004 5:58:58 AM] |
||||
|
||||
![]() coldacid Member since: 6/4/2001 From: Pickering, Canada |
||||
|
|
||||
quote: RTF files are totally self-contained. You don't need to process them to get a final result; they are the final result. And (for XSL styling) if Joe Programmer doesn't have xsltproc, he's not going to want to get it just to view a program trace. |
||||
|
||||
![]() Da cobra Member since: 9/15/2001 From: Belgium |
||||
|
|
||||
| I tried to create a .rtf file with this text : {\rtf1 \ansi \deff0 \fonttbl{\f0 Courier New;} \fs20} {\colortbl; \red255\green255\blue255; \red128\green128\blue128; \red255\green0\blue0; } {\pard \cf0 \b like in your article, but when I try to open it with word, I only get a blanc paper. What is wrong with this code? |
||||
|
||||
![]() TheFez Member since: 10/30/2001 |
||||
|
|
||||
quote: If you ask me, any logging system is better than none. The main plus for RTF is, generally speaking, it can be viewed in any viewer and look the same in each one. HTML and XML on the other hand can look completely different depending on the browser. Try using a span in IE and NS and watch the difference (not to mention differences between versions of IE and NS). If your good at using CSS/XSL it can be much nicer looking than RTF though. Not to mention you can use XML/HTML for many more useful things than RTF files (the favorite one of mine is using it for a "journal" for RPGs so people can share experiences/stories online). |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
quote:There should be a '{' after the '\deff0' (there seems to be a typo in the article), and you forgot the final '}' that is the footer. {\rtf1
\ansi
\deff0{
\fonttbl{\f0 Courier New;}
\fs20}
{\colortbl;
\red255\green255\blue255;
\red128\green128\blue128;
\red255\green0\blue0;
}
{\pard \cf0 \b \b0 Direct3D initialized successfully\par}
} |
||||
|
||||
![]() axon Member since: 1/5/2002 From: Australia |
||||
|
|
||||
| Any suggestions on how to support multi-threading? (ie. what if you're streaming out a log from 2 threads at the same time.) Where can the mutexes be put without deadlocks etc? |
||||
|
||||
![]() BiGF00T Member since: 2/28/2004 From: Germany |
||||
|
|
||||
| i liked colors in the rtf log files BUT - how can i close the last tag if my program crashes before i can call the function to close it? - if you use office and you test your app and you have the rtf file still opened then your program doesnt start because it can't write to the file. but if i close word while running my program i have to restart it and that can take several annoying seconds. i think html would be a better choice for me (even if it looks different in different browsers. but nevertheless nice article. it should be easy to modify the code to do html. thx :) |
||||
|
||||
![]() Mike29936 Member since: 7/16/2003 From: Portland, USA |
||||
|
|
||||
Very useful code. I can now double-click my log and have nicely formatted output displayed in Wordpad.Quote: That seems to be a problem with Office, not the code or RTF in general. Use Wordpad to view RTF files. |
||||
|
||||
![]() wackatronic Member since: 5/29/2004 From: Keller, TX, United States |
||||
|
|
||||
Quote: I know this is an old thread but did anyone think of this. I would like the log file to be daily and backed up for 30 days. One requirement is to provide parsing and make it searchable in some manner? any ideas? -- Eric |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|