0

I like having log data in a last-first form (the same way most blogs and news sites organize their posts).

The languages I'm most comfortable in are C++ and Python: is there a way to output log data either to the screen (stdout) or a file with the most recent entry always being on top?

Or is there perhaps a way of modifying tail to show the latest lines in a scrolling-down fashion rather than scrolling-up?

Would this entail needing a windowing system a la ncurses?

warren
  • 32,620
  • 21
  • 85
  • 124
  • If your log entries are single lines, just use tac – William Pursell Oct 19 '10 at 15:59
  • @William Pursell, as an external tool, that looks like it has promise .. is there an easy way of doing the same with my own applications without tearing-apart `tac`? Also, does it read from end to front, or front-to-end? Will it continue to update is the file is updated? – warren Oct 19 '10 at 16:07

2 Answers2

4

using the tac command you can also do :

watch "tac file.log"

add the -n option if you want to control the refresh time like this

watch -n 0.3 "tac file.log"
mouad
  • 67,571
  • 18
  • 114
  • 106
1

Terminal and console drivers are designed for displaying output in a top-down matter. You will need to resort to an external display manager (ncurses, an HTML layout engine, etc.) if you want to display output in the other direction.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • do you know of any drivers that will display in a bottom-up form for file writing? – warren Oct 20 '10 at 15:47
  • They're strictly for text output to a display, so your question is meaningless. – Ignacio Vazquez-Abrams Oct 20 '10 at 16:09
  • no, my question is distinctly **NOT** "meaningless", Ignacio. If there is a such a driver that will display bottom-up, and shell redirection works, then it *should* write the file from "end to front" (as it were) – warren Oct 21 '10 at 13:51
  • Yes, it is. Even if the file is *displayed* bottom-up, as soon as it is redirected it will be written from beginning to end, because that is how filesystems work. – Ignacio Vazquez-Abrams Oct 21 '10 at 14:30
  • Maybe I'm looking for a different fs... do you know of any that would fit that bill? – warren Oct 25 '10 at 02:23