15 Commits

Author SHA1 Message Date
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