Commit Graph

259 Commits

Author SHA1 Message Date
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
14b8dbc4d8 Miniman changes to make testlog work.
testlog.c can never have worked, or then it cannot have been
kept up to date for a very long time.
2015-11-11 13:41:26 +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
43c7ccdd08 Whitespace and indentation changes.
Whitespace and indentation changes of log manager test programs.
2015-11-09 10:40:13 +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
834a88aeda Log variables moved to log_manager.h
The log manager variables lm_enabled_log_files_bitmask, log_ses_count
and tls_log_info that earlier were declared separately in every
c-file are now declared in the log_manager.h header.
2015-11-04 14:26:53 +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
4c0406a69c New logging macros
This commit is only to introduce new logging macros.

The current implementation is such that a statement like:

    MAXSCALE_NOTICE("Refreshing configuration following SIGHUP\n");

is equivalent with

    LOGIF(LM, (skygw_log_write(
                LOGFILE_MESSAGE,
                "Refreshing configuration following SIGHUP\n")));

The actual implementation will later be changed as the logging
mechanism itself is changed.

The names of the macros are now according to the levels of syslog
and currently the mapping is like:

    MAXSCALE_ERROR   (Syslog LOG_ERR)     -> LOGFILE_ERROR
    MAXSCALE_WARNING (Syslog LOG_WARNING) -> LOGFILE_ERROR
    MAXSCALE_NOTICE  (Syslof LOG_NOTICE)  -> LOGFILE_MESSAGE
    MAXSCALE_INFO    (Syslog LOG_INFO)    -> LOGFILE_TRACE
    MAXSCALE_DEBUG   (Syslog LOG_DEBUG)   -> LOGFILE_DEBUG

When log manager is changed to deal "natively" with syslog levels
this mapping will disappear of course.
2015-10-28 10:01:24 +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
29e241ee60 __func__ instead of __FUNCTION__
The former is part of the C99 standard while the latter is
a GCC extension.
2015-10-23 12:52:55 +03:00
3751299731 Bool arguments replaced with enum.
Mush easier to see at the call-site what actually is done.
2015-10-22 16:05:23 +03:00
d93d01b116 General tidying
General tidying and correction of missed points during
earlier cleanup steps.
2015-10-22 14:54:03 +03:00
20364a132b Whitespace changes.
All binary operators surrounded by a space.
2015-10-22 14:40:57 +03:00
cb468be04f Function declarations changed to common Maxscale style. 2015-10-22 14:26:41 +03:00
18181e8cb9 All keywords now followed by space.
Plus some missing Allman identation fixes.
2015-10-22 10:58:32 +03:00
ba23fc6fa2 Structures renamed according to style guide.
Structures renamed according to style guide and forward declaration
moved from header (where they are not needed) to implementation.
2015-10-21 14:54:41 +03:00
f47b6324a1 Allman indentation style applied. 2015-10-21 14:54:19 +03:00