Fails if no file names can be found when file globbing is on
If file globbing is enabled and no files can be found to match the pattern,
sarg must fail as it does when file globbing is disabled (that was how
sarg worked before file globbing was programmed).
It is meant as a safety in case there is a problem with the generated log
files.
Don't display the period covered by the logs if it is empty
Sarg outputs a line with the earliest and latest dates found if the logs
but it displays 00/01/00 if no log was found. It is best not to display
anything in that case.
Frederic Marchal [Mon, 25 May 2015 18:14:05 +0000 (20:14 +0200)]
Read the useragent log even if no report date is specified
The useragent log was ignored if the report date was not defined on the
command line. The only way to generate the useragent log was to use
command line option -d.
xgettext needs to know what argument of debuga is a c-format string to add
the proper flag in the po file. The printf-like argument changed place when
the source file and line number were added to debuga.
Function debugaz was not declared as a function taking a printf like
argument.
Display the source of the message displayed on stderr
Messages that have been merged in previous commits cannot be distinguished
from each other. It makes debugging more difficult.
To solve this problem, when sarg is run with -zzz, the source file name
and the line number is displayed in the message prefix. It makes it easy to
look at the corresponding source code and understand why the message was
printed.
There were far too many redundant messages to be translated just to report
errors in the data read from a file. The messages have been merged to
reduce the diversity in vocabulary.
To reduce the number of messages to translate, the index reported in the
message is always an int. There was no reasons to use something else in the
first place.
Translated messages that differ only in the file name printed at the
end of the message are now split in two parts. The file name is taken out
of the translated message to leave only the common part to be translated.
Frederic Marchal [Thu, 19 Mar 2015 19:56:30 +0000 (20:56 +0100)]
Get rid of the dependency to an external tail command
The real time report relied on an external "tail" command to get the last
lines of the input log file. That dependency has been removed.
Moreover, if several log files were passed, the real time report would
always read the first one. Now, sarg chooses the most recently modified log
file.
The input log file can be in any supported format. It doesn't have to be
a standard squid log format.
Including gettext.h produces an error because LC_MESSAGES is not declared
by MinGW. To solve this, the gettext.h file isn't included on MinGW and
the missing functions are manually declared.
mkdir with one argument produces an error as the macro requires two
arguments. I couldn't find which macro it is!
mkdir with two arguments doesn't work as _mkdir isn't defined without
direct.h.
_mkdir isn't defined without direct.h and direct.h cannot be included
unless NO_OLDNAMES is defined to mask the mkdir macro which conflict with
the definition in io.h.
Display some debug messages when -z is used to track the progress
When processing a big log file, sarg would remain silent for some time even
with -z enabled. With those messages, the user understand what is
happening.
Proxy authentication code is ignored when building the report
The user report excludes HTTP code 407 meaning that the proxy requires an
authentication.
It must be excluded too when summing up the downloaded size while reading
the input log. The previous code aborted with an error if
--enable-extraprotection was used and the log contained a 407 code.
Increase the buffer size to sort some user reports
The buffer to prepare the sort command to sort the files required to build
siteuser.html and sarg-sites was very small and was not big enough if the
user ID was unusually long.
Frederic Marchal [Fri, 12 Dec 2014 16:23:45 +0000 (17:23 +0100)]
Improve the message helping the user to set the translation up
It isn't easy to figure out where sarg searches for sarg.mo. Running sarg
like sarg -x -v display the usual version number and a message giving
enough information to know where to put the message file.
Frederic Marchal [Thu, 11 Dec 2014 14:01:23 +0000 (15:01 +0100)]
Display locale information for debugging purpose
Running sarg -x -v display the version number but also the directory where
the message file is looked for, the package name and the currently
selected locale.
Frederic Marchal [Wed, 10 Dec 2014 20:28:17 +0000 (21:28 +0100)]
Display a column with the user's IP address in the top user report
In sarg.conf, topuser_fields accept the new USERIP parameter to display
a new column with the user's IP address. It is only useful if the IP
address is replaced by a name or resolved to a host name.
Log file names are stored in a tree to save space. They have to be merged
back when the full file name is required. But an error prevented the file
name from being reconstructed if two files were stored in different
directories and one node of the tree has a lower depth than the next
one.
When index_tree is set to "date", the reports are stored in a tree based
on their content's date. The existing code was somewhat broken.
In addition, the directory size used to be computed and displayed in the
years index file. It is now computed and displayed in the months and days
indexes.
Delete old reports when index_tree is set to "date"
Sarg goes to great length to make sure no unrelated directories are
deleted.
A list of every report directory is build. It is sorted in ascending order
on the last modification time. If too many directories are present, the
oldest ones are deleted including the possibly remaining empty parent
directory.
The index.html file is not rebuild to account for the deleted reports yet.
Use a global constant instead of the "index.html" file name in the code
The name of the html index file is defined once in the source code as a
global constant instead of littering the source code with a hard coded
litteral string.
Verbose output with correct period covered by the logs
Previous versions reported the period covered by the log but it was, in
fact, the period extracted from the log limited to the requested range.
Now, two distinct messages are displayed in verbose mode. The first is the
period really covered by the log files. The second is the range taken into
account to produce the report.
Use the last modification time to sort the old reports directories. The
previously used ctime is not the creation time but the time at which the
directory meta data was last modified.
Creating the old report list don't use temporary files nor the external
sort command. Everything is kept and sorted in memory.
The code make sure the report directory looks like one of our report
directory. This is a safety to avoid deleting an unrelated directory.
Currently this safety mechanism only detects directories created with in
index_tree set to "file".
I used to always forget to update the ChangeLog before releasing sarg. It
won't happen if the archive script check that the ChangeLog contains an
entry for the current version and release date.
This patch was suggested by Diego Elio Pettenò on May 25, 2011 and
implemented in commit b966a3a224de2a6ea591458bec47c1bb4e9b3745 but the
patch had not been applied to the CMake build file.
Some systems define _FORTIFY_SOURCE by default. It conflicts with our use
of that macro when --enable-extraprotection is passed to the configuration
script.
The solution is to undefine it before redefining it with value 2.
If a higher _FORTIFY_LEVEL level ever appears, it will have to be used in
this program to benefit from the highest protection possible.
Frederic Marchal [Sun, 15 Jun 2014 14:44:56 +0000 (16:44 +0200)]
Help in diagnosing the number of old reports to keep
The lastlog and lastlog1 files are stored in the temporary directory
instead of the output directory and they are not deleted when sarg exits
if the user asked not to delete temporary files.
Some debug messages give indication about what is happening with respect
to the old reports deletion.
If sarg is ran with option -l combined with any other option such as -xl,
then the -l option is mistaken as --lastlog and does not produce the
expected result (which is to use the access.log file passed as argument).
It has been fixed by requiring that any long option is préfixed with a
double dash.
It breaks the compatibility with old versions but nobody should notice.
Thanks to Leonardo Rodrigues for reporting this bug.