37 Commits

Author SHA1 Message Date
Johan Wikman
b84dbd8d3f MXS-357: Possibility to turn off log message augmentation.
It's not always desireable to have the function name
appended to every logged line.
2015-09-09 10:59:22 +03:00
Johan Wikman
0779673403 MXS-228: Include file name and line numbers
This change does not log the file name and line numbers,
but the function name. Together with the commit information
that is logged in conjunction with a crash and that MaxScale
can tell, when invoked, that is enough to be able to pinpoint
the location where a logging was made. Furthermore, that is
a lot less intrusive and less confusing for an
end-user than filename + line.

This is just a temporary workaround; the logging mechanism
needs to get an overhaul:

- Separate severity and logging target.
- Take syslog severities into use.
- Simplify what needs to be done by developer.
- etc.
2015-09-07 12:32:32 +03:00
Johan Wikman
160bbb70ee MXS-251: strerror
Replaces all calls to strerror with calls to strerror_r. The former
is non-thread safe while the latter is.
2015-09-05 15:52:13 +03:00
Johan Wikman
6601dfaaa0 Removed all trailing whitespace. 2015-08-31 13:00:59 +03:00
Markus Makela
1b91f776a3 Added option to disable logging to MaxScale's log files. 2015-03-09 19:38:37 +02:00
Markus Makela
1ff0756044 Added a command line option for syslog logging. 2015-03-05 12:37:39 +02:00
Markus Makela
ad49c5f402 Added optional millisecond precision to logfiles and created the changelog document. 2015-02-24 18:10:16 +02:00
VilhoRaatikka
6be227f3c4 Added comments, removed non-existing function, cleaned up a bit. 2015-01-12 14:25:37 +02:00
Timofey Turenko
8572a08cab Merge branch 'master' into develop 2015-01-09 11:23:03 +02:00
Markus Makela
3bf595673d Added the missing skygw_log_sync_all function to the log_manager.h header and created a header for testing which contains the location of the testing directory. 2015-01-05 06:48:32 +02:00
Markus Makela
b07df3b296 Renamed and improved the synchronous log flushing function. 2014-11-25 16:04:23 +02:00
Markus Makela
5eaf963ad4 Removed unnecessary debug information and return values. 2014-11-25 14:47:50 +02:00
Markus Makela
3d50d8f117 Added a function that flushes all logfiles synchronously. 2014-11-25 14:43:43 +02:00
VilhoRaatikka
fd11e6a7f5 Session-specific logging. Added functions
void session_enable_log(SESSION* ses, logfile_id_t id)
and
void session_disable_log(SESSION* ses, logfile_id_t id)

Which switch specific log type on/off if the log type in question is not generally enabled.

Each thread carries a thread-specific struct log_info_t which includes members for current session id and bitfield for enabled log types for the current session. That information is checked before actual log write functions are called.

Each file where session-specific logging is used, must include the following exports:

/** Defined in log_manager.cc */
extern int            lm_enabled_logfiles_bitmask;
extern size_t         log_ses_count[];
extern __thread log_info_t tls_log_info;
2014-11-19 00:08:59 +02:00
VilhoRaatikka
8af97016bb Dummy for skygw_log_rotate. 2014-11-11 18:33:17 +02:00
VilhoRaatikka
00fded016b Fixes to Coverity tasks : 73267, 72686, 72672
Cleaned up warnings, and added checks to malloc return values and error log writes in case of failures.
2014-10-31 15:25:59 +02:00
Markus Makela
b0683d9b4d Updated the licensing year from 2013 to 2013-2014 2014-10-01 14:37:12 +03:00
Markus Makela
f4e591e382 Changed 'SkySQL Gateway' to 'MariaDB Corporation MaxScale' 2014-09-30 13:15:03 +03:00
Markus Makela
c344231f80 Renamed all occurences of SkySQL to MariaDB Corporation 2014-09-30 13:02:10 +03:00
Mark Riddoch
a16f900d6d Merge branch 'hholzgra-hartmut-compile-warnings' into release-1.0beta-refresh
Conflicts:
	server/include/dcb.h

Resolved
2014-09-19 17:37:39 +01:00
Markus Makela
4028c50fea added state based block buffers to log manager 2014-09-10 12:09:00 +03:00
Hartmut Holzgraefe
25c5d1af25 fixed some warnings about const -> non-const conversions 2014-08-26 18:25:28 +02:00
vraatikka
272ca036e4 log_manager.h
Added macros which allow for testing locally if log is enabled or not.

server/Makefile
	Added directory creation command to Makefile. This fixes problem where errmsg.sys was copied to MaxScale/mysql instead of MaxScale/mysql/errmsg.sys

dcb.b
	Added external variable which carries the information of enabled logs from log_manager.cc

gateway.c
	Tuned logging.
2013-12-12 07:05:38 +02:00
vraatikka
9ba7a0d955 log_manager.cc
Added new argument '-s' which takes additional argument composed of list of logfile identifiers. Logfiles listed with '-s' will be written on main memory instead of disk. In practice, the log file in question will be written in /dev/shm but corresponding symlink is added to log directory. In the case of name conflicts with log files and links, a differentiating sequence number is included in hte name of the file. This, however, is done only when existing file is not writable or is of different type (symlink <> file). 
	Added new logfile LOGFILE_DEBUG whose contents will be largerly what was included up to date in trace log. 

	Disabled feature which spreads writes to log files to others because of bug (#338) in the way block buffers are managed.

	Changed log manager parameters to match with the current implementation. List of arguments:
                "-h - help\n"
                "-a <debug prefix>   ............(\"skygw_debug\")\n"
                "-b <debug suffix>   ............(\".log\")\n"
                "-c <trace prefix>   ............(\"skygw_trace\")\n"
                "-d <trace suffix>   ............(\".log\")\n"
                "-e <message prefix> ............(\"skygw_msg\")\n"
                "-f <message suffix> ............(\".log\")\n"
                "-g <error prefix>   ............(\"skygw_err\")\n"
                "-i <error suffix>   ............(\".log\")\n"
                "-j <log path>       ............(\"/tmp\")\n"
                "-s <shmem log file ids> ........(no default)\n";

dcb.c
	dcb_add_to_zombieslist, add dcb to the front of zombies list instead of inserting to the end of it.

gateway.c
	Renamed shutdown_gateway to shutdown_server (Bug #131)
	Call skygw_logmanager_init so that trace and debug logs are written to shared memory.

poll.c 
dcb.h
	Removed some dead code and references to unneeded mutexes.

debugcmd.c
	Added enable/disable log command for debug log.

skygw_utils.cc
	skygw_file_init now takes optional symlink name as a second argument. Symlink is created to point to the file being created.
2013-11-08 12:56:39 +02:00
vraatikka
15adf134c4 Defined LOGFILE_DEBUG for future use. If there will be separate logfile for debug output then macro will be removed. Currently equals with LOGFILE_TRACE. 2013-09-12 22:01:05 +03:00
vraatikka
c2743e7543 Logfiles are ordered by their id as follows:
LOGFILE_ERROR   = 1
LOGFILE_MESSAGE = 2
LOGFILE_TRACE   = 4

What is written to file n, will be written to all files m, m>n. Applies to user log writes. Some internal messages are such that they apply to one specific file, such as enable/disable notifications.
2013-08-19 10:28:28 +03:00
vraatikka
0ad25ba3ab Added functions skygw_log_enable(logfile_id_t) and skygw_log_disable(logfile_id_t) to Log manager API. By calling them log writing to any of predefined log files can be switched on or off.
Added simple test to testlog.c
2013-08-08 23:38:00 +03:00
vraatikka
9fb072ea74 Changed log manager APChanged log manager APII 2013-08-04 23:14:48 +03:00
vraatikka
d2efbcf867 Changed log manager API. Removed unnecessary memory context pointer (always NULL):
bool skygw_logmanager_init(void** buf, int argc, char* argv[]) >>
bool skygw_logmanager_init(int argc, char* argv[])

void skygw_logmanager_done(void** buf) >>
void skygw_logmanager_done(void)

void skygw_log_done(void* writebuf) >>
void skygw_log_done(void)

int  skygw_log_write(void* writebuf, logfile_id_t id, char* format, ...) >>
int  skygw_log_write(logfile_id_t id, char* format, ...)

int  skygw_log_write_flush(void* writebuf, logfile_id_t id, char* format, ...) >>
int  skygw_log_write_flush(logfile_id_t id, char* format, ...)

--- static functions :
static bool logmanager_init_nomutex(void** p_ctx, int argc, char* argv[]) >>
static bool logmanager_init_nomutex(int argc, char* argv[])

static void logmanager_done_nomutex(void** ctx) >>
static void logmanager_done_nomutex(void)
2013-08-04 23:07:54 +03:00
vraatikka
6abd9dbdaa Added profile counters: writebuffer init, done, total and recycle counts. 2013-07-02 16:53:23 +03:00
vraatikka
d11741130d Changed log manager API to support variable length formatted log strings. New API is as follows:
/** No change in these */
bool skygw_logmanager_init(void** buf, int argc, char* argv[]);
void skygw_logmanager_done(void** buf);
void skygw_logmanager_exit(void);
int  skygw_log_flush(logfile_id_t id);

/** writebuf remains unused, but formatted string is now possible and in case 
 * of formatted string, arbitrary long argument list is supported too. Max 
 * length for a log string is defined to BUFSIZ, whose value depends on the 
 * system but typically is 4/8KB.
 */
int  skygw_log_write(void* writebuf, logfile_id_t id, char* format, ...);
int  skygw_log_write_flush(void* writebuf, logfile_id_t id, char* format, ...);

makefile.inc includes new CFLAG : SS_PROF, which is set if PROF=Y on make command line or in build_gateway.inc .
ss_debug.h includes corresponding ss_prof(exp) macro which equals to exp if SS_PROF is defined and to empty if in other case.

mlist_t now includes datadel function which is a callback and it is executed for mlnode_data on node exit.
2013-07-02 14:46:39 +03:00
vraatikka
1888b8a517 Prevented redefinition of bool, added function void skygw_logmanager_exit(void) to be called by atexit 2013-06-28 11:39:00 +03:00
vraatikka
5c271e1925 Fixed clean-up processes in cases where initialization fails arbitrarily in the middle of startup. Added four descriptive states : UNINIT, INIT, RUN, DONE for flat stucts inside logmanager. Flat structs always have the state which tells what needs to be fred, if any. 2013-06-27 16:43:01 +03:00
vraatikka
9630ae588e Fixed bugs and cleaned code 2013-06-27 12:18:25 +03:00
vraatikka
ef1d198654 Changed log manager API so that pointer reference to logmanager is not used anymore. Every call initializes logmanager now except skygw_logmanager_done and skygw_log_flush.
skygw_logmanager_init is still useful because it allows for providing memory address for log manager where it can store a list of preallocated write buffers. TBD.

Logmanager access is now protected with spinlock familiar from epoll/core/spinlock.c . It is modified to avoid trashing; misses are counted and every tenth subsequent lock acquiring attempt triggers short random sleep.
2013-06-26 23:13:40 +03:00
vraatikka
2ea8e2a05a Added licences and changed the use of zero-length arrays due to compiler problems. 2013-06-26 09:39:38 +03:00
vraatikka
8178e4e239 New, yet primitive version of log writing functionality. Fixed some things in utils. 2013-06-25 21:14:03 +03:00