Commit Graph

216 Commits

Author SHA1 Message Date
c71610d7d4 Rename error.log to maxscale.log
Since there is but one log file where error, warning, notice, info
and debug messages are written, calling it "error.log" is misleading.
Consequently the log file is renamed to "maxscale.log".
2015-11-30 11:10:36 +02:00
384029c109 MaxScale log called consistently for maxlog
There were some variance regarding the way the MaxScale log (i.e.
the file log) was called; "maxlog" in configuration file and
"maxscalelog" at the command line and maxadmin interface. Now it
is uniformly referred to as "maxlog" in the configuration file, at
the command line, from maxadmin and in the code.
2015-11-27 16:10:37 +02:00
2bfcf7e88a Enable LOG_WARNING by default.
In addition the error and notice messages, also warning messages
are enabled by default.
2015-11-27 16:08:49 +02:00
916ee5ff2a Rename some log concepts
The mxs prefix is now uniformly used with all log components.
2015-11-26 17:34:53 +02:00
01f2aa8d1b All but LOG_INFO and LOG_DEBUG are logged to syslog.
*If* syslog logging is enabled, then all messages but LOG_INFO
and LOG_DEBUG are logged to syslog.
2015-11-25 09:24:48 +02:00
af6ec7f346 Allow [en|dis]abling of [sys|maxscale]log via maxadmin.
The syslog and maxscalelog can now be enabled and disabled at
runtime using maxadmin.
2015-11-25 09:16:17 +02:00
a8535f42af Remove all traces of logfile_t
The earlier log file based approach for enabling and disabling
messages has now been completely replaced with the syslog priority
based approach.

Similarly as with log files before it is now possible to enable
and disable a log priority for a particular session, even though
it apparently has not been used much.

The local test-programs of the logging has got minimal attention
only to make them compile. They should get an overhaul as they did
not work before either.
2015-11-23 19:10:53 +02:00
0345f3622d LOGIF and skygw_log_write removed.
All places where LOGIF and skygw_log_write were used have been
updated to use the new logging macros instead. Consequently,
they can now be removed.
2015-11-19 09:26:27 +02:00
b8fda016c9 Log: Some cleanup.
Stuff that does not need to be in the header moved to the
implementation file.
2015-11-15 19:43:45 +02:00
bcb918e60b Log: Another step in the move from logfiles to priorities.
skygw_[enable|disable]_log has now been removed from the external
interface and priorities must instead be set using
mxs_log_set_priority_enabled(int priority, bool enabled). A bitmask
is already being updated, but internally and as used by the LOG_IF
macros, the actual enabling is still made using logfile ids.

The configuration entries have been replaced as follows:

	log_messages -> log_notice
	log_trace    -> log_info

The old ones can be used, but cause a warning to be logged.

Similarily the maxadmin commands have been updated.
"[enable|disable] log ..." works as expected, but there will be
a message about it being deprecated. Instead there is now a
[enable|disable] log-priority err|warning|notice|info|debug
command that should be used instead.
2015-11-14 22:28:17 +02:00
841ec695e4 Incorrect error handling corrected. 2015-11-13 12:48:13 +02:00
2c1b53c120 Log: Cleanup of API
skygw_ functions removed and replaced with mxs_ equivalents.
logfile_id_t removed.
2015-11-12 18:31:53 +02:00
05fbdb1b76 Log: skygw_log_flush replaced with mxs_log_flush.
skygw_log_flush replaced with mxs_log_flush and skygw_log_sync_all
with mxs_log_flush_sync.
2015-11-12 18:28:34 +02:00
c7a329e43e Log: skygw_logmanager_init renamed to mxs_log_init.
skygw_logmanager_init renamed to mxs_log_init and skygw_logmanager_done
renamed to mxs_log_finish. skygw_logmanager_exit removed alltogether as
all it did was to call skygw_logmanager_done. That appears to have been
a source for confusion as in many places a call to skygw_logmanager_done
was followed by a call to skygw_logmanager_exit. In addition, the function
skygw_log_done was removed from the header, since it lacked an
implementation.
2015-11-12 16:06:44 +02:00
bdfd72404b Log: skygw_log_rotate replaced with mxs_log_rotate.
With only one log-file no arguments are needed. The maxadmin command
'flush log'  still accepts all the previous arguments, but warns about
them being deprecated.
2015-11-12 14:48:37 +02:00
3cfd1ee4e8 Log: Logging is now done by priority and not logfile.
The native way for logging is now by syslog priority and not by
logfile id. In practice that means that there's a function -
mxs_log_message - that takes a syslog priority. The new logging
macros (MXS_ERROR and friends) call that directly and the old
ones as well after having the logfile id translated into the
equivalent priority.

What is enabled or not is still by logfile id and hence the
priority is internally translated into a logfile id when checking
whether something really should be logged or not.
2015-11-12 08:40:29 +02:00
b6783c24d0 Log: Some gotos removed. 2015-11-11 15:20:25 +02:00
b4e9dcd567 Log: succp renamed to succ. 2015-11-11 15:18:08 +02:00
001d2df96c Log: Consistency of global variables ensured.
The value of global variables that can change copied before being
accessed to ensure that the used value is the same for the duration
of a function call. No locks are needed, because even if the copying
would not be atomic, it doesn't matter since all that matters is that
the used value does not change for the duration.
2015-11-11 15:05:42 +02:00
42cf1c58d6 No need to handle impossible things.
The string given to logmanager_write_log cannot be NULL.
The id given to logmanager_write_log cannot be invalid.
Consequently we need not handle those possibilities.
2015-11-11 14:42:43 +02:00
acb0a523a7 Log: No more argv parsing for log manager.
Earlier, the global setting for the syslog decided whether syslog
was enabled when skygw_logmanager_init was called, but not whether
logging to syslog actually was made.

Now syslog logging is enabled by default and the global setting
decides whether or not syslog logging actually is made. That is,
this opens up the possiblity for making it possible to turn on
and off sysloging at runtime.

Further, although the API led you to believe otherwise, it was
hardwired that LOGFILE_ERROR and LOGFILE_MESSAGE messages were
written to syslog.

The changed removed the need for passing an argv array explicitly.
2015-11-11 13:53:14 +02:00
0b7de96eff Log: Module variables collected into anonymous struct.
Modules variables collected into anonymous struct. Easier to
see whether something has module scope.
2015-11-11 13:51:20 +02:00
24bed47794 Syslog ident must be provided explicitly.
The syslog ident must be provided explicitly when calling
skygw_logmanager_init (and not provided via the argv array).
It can be NULL, in which case it automatically will be the program
name.

The openlog() call is now always made, irrespective of what the
value of the global syslog flag is. That way it will be possible
to turn syslog logging on or off after the fact.
2015-11-11 13:48:57 +02:00
55dbaa49c0 Logging target must be explicitly defined.
Whether the log-file should be written to the filesystem or to
shared memory must now be explicitly defined when calling
skygw_logmanager_init() (instead of passing that via the argc/argv
construct).

Also, the meaning of '-l' when invoking maxscale has been changed.

Earlier -l [file|shm] specified whether the trace and debug logs
should be written to shared memory (while the error and message
logs always were written to the filesystem) and the _default_
was to write them to shared memory.

Now, with only one file, '-l' has still the same meaning, but it
decides whether the one and only logfile should be written to shared
memory, or the filesystem and the _default_ is to write it to the
filesystem.
2015-11-11 13:47:34 +02:00
abea233a2e If log manager not inited messages are written to stdout.
If the log manager has not been inited, then messages are written
to stdout. In practice this can happen if something is directly or
indirectly logged during the startup of maxscale, before
skygw_logmanager_init() has been called. Some refactoring is needed
to allow skygw_logmanager_init() to be called very early at program
startup.
2015-11-11 13:30:12 +02:00
450078fa92 Interface of skygw_logmanager_init(int argc, char* argv[]) changed.
The previous interface of skygw_logmanager_init was conceptually
broken. With -o you could specify that logging should be done to
stdout. However, even if you did that, the log manager still checked
that the logging directory could be accessed. Unless it had been
specified using -j <path> the default was /var/log/maxscale.

That is, unless the program calling skygw_logmanager_init was invoked
by a user that had write access to /var/log/maxscale, there would be
a complaint even if nothing was ever written to that directory.
In practice this meant that even if -o was used you had to provide
a -j with a path that surely is writeable (e.g. "/tmp").

This has now been changed so that you explicitly must provide the
log directory and the flags -j and -o are removed.

  bool skygw_logmanager_init(const char* logdir, int argc, char* argv[]);

If /logdir/ is provided then logged messages are written to a log file
in that directory. If /logdir/ is NULL then messages are logged to stdout
and no checks for access to any directory is not made.
2015-11-06 14:20:05 +02:00
80344babd7 Log manager additions.
Changes related to the replacement of the notion of logfiles
with the notion of syslog priorities.
2015-11-06 10:06:54 +02:00
e9ff89629b More obsolete functionality removed.
The log manager possibility for explicitly specifying the names
of the log files has never been used. In the name of simplicity
that functionality is removed.
2015-11-04 11:00:38 +02:00
865162dc54 Removed getopt options. 2015-11-04 10:29:42 +02:00
d7af979ad9 Removed obsolete functionality.
No need for debug, trace or messages prefixes or suffixes.
2015-11-04 10:29:42 +02:00
f17803e892 Only one log_file.
The array of log_files replaced with single instance.
2015-11-03 23:27:51 +02:00
633f06cddd The notion of a particular file being enabled is removed.
The one and only message file is always enabled.
2015-11-03 22:52:20 +02:00
3348fab3c4 Only error log is created.
Only the error log is created anymore. The data structures for
the other files still exist, but they are to be removed next.
2015-11-03 22:34:03 +02:00
8798475a46 Some re-arranging of functionality.
Some thread specific functionality moved from thr_flush_file
to the caller thr_filewriter_fun.
2015-11-03 21:50:34 +02:00
4de363e8dd Some log refactoring.
Some log manager refactoring to make it easier to later remove
all files but the error log.

Basically all that was done was to move everything inside the
for-loop of thr_filewriter_fun into a separate function called
thr_flush_file. Otherwise no changes in functionality was made.
2015-11-03 16:05:29 +02:00
9050fce3d4 It only makes sense to flush/rotate the error log.
The other log files are not used.
2015-11-03 14:23:31 +02:00
9ba6ad81b0 Some gotos removed. 2015-11-03 14:21:20 +02:00
6d1c069d41 A bitmask of logfiles is now only logged once. 2015-11-03 11:15:29 +02:00
142c22c2a8 The enabling/disabling of log written to error.log
A change on the path of removing all logs but error.log.
2015-11-02 14:53:35 +02:00
112e21d507 MAXSCALE_ macros renames to MXS_
Markus boldly introduced mxs as an abbreviation for Maxscale.
MXS_ is less wieldy than MAXSCALE_ for logging macros.
2015-11-02 10:11:59 +02:00
3da1769d12 skygw_log_flush no longer calls logmanager_write_log. 2015-10-30 15:26:10 +02:00
217a0ae406 Making logmanager_write_log into less of a kitchen-sink.
logmanager_write_log did three different things - logged a message,
flushed a file and rotated a file - none of which were performed
in one go. Hence there's no reason to do all those things in that
function.
2015-10-30 15:08:46 +02:00
7ac5176b46 Everything logged to one file with severity prefix.
Another step on the road of log manager modifications.

- All messages are now logged to error.log. The other files are
  still created but not used anymore.
- A severity prefix is added, to distinguish between messages logged
  to "different" files:

     LOGFILE_ERROR   => "[Error]:  "
     LOGFILE_MESSAGE => "[Notice]: "
     LOGFILE_TRACE   => "[Info]:   "
     LOGFILE_DEBUG   => "[Debug]   "

  That prefix is not written to syslog.
- When maxscale is built in debug mode, trace and debug messages
  are no longer enabled by default.

Next step is to remove the other files entirelly.
2015-10-30 11:21:51 +02:00
bea4051ad5 Spread down feature removed.
With only one file, the spreading down idea becomes nonsensical.
Furthermore, it has never been enabled due to some problems.
2015-10-29 11:40:51 +02:00
f964938aaf Minor cleanup.
Parameter documentation clarified, same approach followed all through.
2015-10-29 11:39:59 +02:00
22c8af4923 Removed obsolete parameters.
Valist is handled before logmanager_write_log is called. So it
is quite unnecessary to always having to pass a valist whether
it is used or not (and not it is never used).
2015-10-28 15:34:34 +02:00
90ff0f1fdf Augmentation moved.
Augmentation moved to skygw_log_write_context. The severity prefix
will be added there as well. If all is done on that level, the
amount of memory needed can be figured out in one go. No need to
allocate and copy the message several times.
2015-10-28 15:16:32 +02:00
ddcfe03c15 Removed duplicate code. 2015-10-26 15:16:54 +02:00
f2c5df703b Added an ellipsis at the end of a log message that exceeds the maximum size. 2015-10-26 12:15:24 +02:00
6c6f81abce Fix to MXS-427: https://mariadb.atlassian.net/browse/MXS-427
Stack allocated buffers now have a maximum size.
2015-10-26 10:06:20 +02:00