Click here to Skip to main content
15,867,308 members
Articles / Desktop Programming / MFC
Article

A real time log file viewer

Rate me:
Please Sign up or sign in to vote.
4.81/5 (19 votes)
17 May 20042 min read 172K   4.5K   58   28
A real time log file viewer.

ABLogFile Screen Shot

Introduction

ABLogFile is a very simple and easy to use real time log file viewer. All that is required is to open a text based log file, this program will check for any changes to the file and automatically display them on the screen. The new changes are displayed in a bright color and then fade to the normal text color. It also automatically scrolls to the newest line. ABLogFile supports a very basic find function.

Background

This program was thought up in the early hours of the night a couple of weeks ago. I was doing some work, a program that updated a file every couple of seconds. My problem was, if I wanted to see the changes, I had to keep reopening the file, thus ABLogFile was thought of.

Points of Interest

The hardest part of the project was how to organize the data in memory, so that it is easy to add new data, keep track of the changes, and quick to display the data. What I ended up doing after a number of sleepless nights of coding, was to store the entire log file in memory, create an array of pointers that point to the starting position of each line, and another array of sections which keep track of the changes to the log file. Another tricky bit was to work out what the line delimiter was in the file, the way that I ended up writing it was to search for a number of different delimiters, this part will definitely be redesigned shortly. Apart from the above mentioned, it was pretty straight forward.

Limitations

Of course, there are some limitations:

  • The log file is currently stored in memory, therefore there may be a problem viewing very large files.
  • With the way that the auto delimiter works, if the second line is blank then the file will not be displayed properly.
  • This program will only keep track of data newly appended to the file, it will not work with data getting changed in the file.

Acknowledgements

  • Tabbed MDI view Copyright © by Dundas Software.

History

I believe this project to be of great benefit, I will be willing to add features as people suggest them. This program currently does what was originally required by myself. So, please let me know of any features required.

  • V 1.0.0.1 2004-05-13
    • First public release of binary and source code.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Australia Australia
Started programming many many years ago, now a full time C++ developer writing medical software. I have also been known to dabble in electronics. Currently looking to go back to university to study electronic engineering.

Comments and Discussions

 
QuestionHow to use it ...? Pin
zit_gir15-Jul-05 20:41
zit_gir15-Jul-05 20:41 
AnswerRe: How to use it ...? Pin
amleth15-Jul-05 21:00
amleth15-Jul-05 21:00 
GeneralNew Version Available Pin
amleth1-Jul-04 18:22
amleth1-Jul-04 18:22 
GeneralUnable to load file > 1MB thru mapped drive Pin
Hilary Wong27-May-04 18:00
Hilary Wong27-May-04 18:00 
GeneralRe: Unable to load file > 1MB thru mapped drive Pin
amleth27-May-04 18:16
amleth27-May-04 18:16 
GeneralA nice, freeware alternative: baretail Pin
dtr227-May-04 1:51
dtr227-May-04 1:51 
GeneralVer 01.00.02.00 Pin
amleth26-May-04 17:41
amleth26-May-04 17:41 
GeneralRe: Ver 01.00.02.00 Pin
Jaroslav Klumpler27-May-04 23:20
Jaroslav Klumpler27-May-04 23:20 
GeneralRe: Ver 01.00.02.00 Pin
sylvain222228-May-04 5:53
sylvain222228-May-04 5:53 
GeneralEven more troubles Pin
Jaroslav Klumpler26-May-04 1:15
Jaroslav Klumpler26-May-04 1:15 
GeneralRe: Even more troubles Pin
amleth26-May-04 2:09
amleth26-May-04 2:09 
GeneralRe: Even more troubles Pin
Jaroslav Klumpler26-May-04 2:52
Jaroslav Klumpler26-May-04 2:52 
GeneralTabs Pin
Stanislav Yelenskiy25-May-04 23:39
Stanislav Yelenskiy25-May-04 23:39 
GeneralRe: Tabs Pin
amleth26-May-04 0:54
amleth26-May-04 0:54 
GeneralNice try but... :-) Pin
PeterHarrie25-May-04 23:26
PeterHarrie25-May-04 23:26 
GeneralRe: Nice try but... :-) Pin
amleth26-May-04 1:02
amleth26-May-04 1:02 
GeneralAhhh, for some tail -f logfile.txt Pin
Anonymous25-May-04 13:50
Anonymous25-May-04 13:50 
GeneralSetting Pin
Bydia20-May-04 16:22
Bydia20-May-04 16:22 
GeneralRe: Setting Pin
amleth20-May-04 16:54
amleth20-May-04 16:54 
Thanks,

I will have a look at doing something about the CPU usage. Currently it checks the file size every 100ms, I don't know any other way of doing it.

What i was thinking of doing something like, when polling if it hasn't changed then double the time to the next poll interval. I will also add a setting to set the poll interval.

I will update the Code in the next day or so.



Regards

Amleth Ojalen

ABLogFile
ABBaseCalc
ABHotKeys
GeneralRe: Setting Pin
Bydia20-May-04 18:39
Bydia20-May-04 18:39 
GeneralRe: Setting Pin
amleth20-May-04 18:48
amleth20-May-04 18:48 
GeneralTraceTool Pin
Thierry Parent18-May-04 6:52
Thierry Parent18-May-04 6:52 
GeneralRe: TraceTool Pin
amleth18-May-04 9:41
amleth18-May-04 9:41 
GeneralTroubles Pin
JCrane218-May-04 6:31
JCrane218-May-04 6:31 
GeneralRe: Troubles Pin
amleth18-May-04 9:36
amleth18-May-04 9:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.