Commit Graph

282 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
a829b38873 Fix to MXS-363: Added soname versions to libraries
The soname version numbers were missing from all the library targets
properties which caused ldconfig to warn about non-symlink libraries
being installed.
2015-11-30 10:46:08 +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
62b0e5fab0 Session info always copied to tls
Maxadmin earlier gave the impression that you could change whether
messages for different log files could be specifically enabled for
a session. In practice that was true only for trace messages as the
session id and the bitmask telling what logfiles are enabled, were
copied to thread local storage only as far as trace messages were
concered.

The code for setting that information in place is quit short and
efficient, so there is really no reason not to do that always.
This also means that it always will be possible to get your hands
on the session object if there is a need for that.
2015-11-23 18:14:46 +02:00
6164b7f301 Fixed unsafe use of localtime
Since localtime is not thread-safe it should not be used in multithreaded
contexts. For this reason all calls to localtime were changed to localtime_r
in code where concurrency issues were possible.

Internal tests were left unchanged because they aren't multithreaded.
2015-11-19 17:17:16 +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
fb443a9f92 LOGIF removed from readconnroute.c 2015-11-17 12:48:47 +02:00
a355e1beef Printf format checking added to logging function.
Printf format checking added to logging function and all
issues that were revealed by that fixed.
2015-11-16 12:40:49 +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
86dcd1cc0f LOGIF_MAYBE macros cleaned away.
Used in few places and only obscured what was going on.
2015-11-14 21:51:27 +02:00
8d0bd8150a Merge branch 'MXS-329-develop-20151111' into develop 2015-11-13 17:26:34 +02:00
841ec695e4 Incorrect error handling corrected. 2015-11-13 12:48:13 +02:00
6b88b6b17f Merge branch 'develop' into MXS-329-develop-20151111 2015-11-13 07:48:59 +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
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
dee20fe077 Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111
# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
2015-11-11 11:08:02 +00: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