To fix this code-side rather than client-side, you need to instruct your code to use Windows-style line endings. In your code, wherever you see "\n", use "\r\n" instead. If there are a great number of places that you've already used "\n" and you don't want to hunt them down, you could also use a short Perl script to convert them right before viewing. This might look like:
This is untested#!/usr/bin/perl use strict; use CGI::Simple; my $q = new CGI::Simple; $| = 1; print $q->header( -type => 'text/plain', -expires => '+1m' ); ## the header is for plain text, and the data expires in 1m ## If there's no file parameter, exit with an error message unless ($q->param('file')) { print 'No File was requested'; exit; } open LOG, '<', $q->param('file') or do { # exit with error if we can't open the file print 'Unable to open file ',$q->param('file'),':',$!; exit; }; while (<LOG>) { s{(\r\n)|(\n)}{\r\n}g; ## replace unix with Win line-endings print $_; }
This should be invoked as http://www.domain.com/myname.pl?file=logs.txt (if you named your script 'myname.pl').
The Eightfold Path: 'use warnings;', 'use strict;', 'use diagnostics;', perltidy, CGI or CGI::Simple, try the CPAN first, big modules and small scripts, test first.
In reply to Re^3: log file formatting
by radiantmatrix
in thread log file formatting
by centrum
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |