~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log.h

First pass of removing historical logging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
  friend class Log_event;
200
200
};
201
201
 
202
 
class DRIZZLE_QUERY_LOG: public DRIZZLE_LOG
203
 
{
204
 
public:
205
 
  DRIZZLE_QUERY_LOG() : last_time(0) {}
206
 
  void reopen_file();
207
 
  bool write(time_t event_time, const char *user_host,
208
 
             uint user_host_len, int thread_id,
209
 
             const char *command_type, uint command_type_len,
210
 
             const char *sql_text, uint sql_text_len);
211
 
  bool write(THD *thd, time_t current_time, time_t query_start_arg,
212
 
             const char *user_host, uint user_host_len,
213
 
             uint64_t query_utime, uint64_t lock_utime, bool is_command,
214
 
             const char *sql_text, uint sql_text_len);
215
 
  bool open_slow_log(const char *log_name)
216
 
  {
217
 
    char buf[FN_REFLEN];
218
 
    return open(generate_name(log_name, "-slow.log", 0, buf), LOG_NORMAL, 0,
219
 
                WRITE_CACHE);
220
 
  }
221
 
  bool open_query_log(const char *log_name)
222
 
  {
223
 
    char buf[FN_REFLEN];
224
 
    return open(generate_name(log_name, ".log", 0, buf), LOG_NORMAL, 0,
225
 
                WRITE_CACHE);
226
 
  }
227
 
 
228
 
private:
229
 
  time_t last_time;
230
 
};
231
 
 
232
202
class DRIZZLE_BIN_LOG: public TC_LOG, private DRIZZLE_LOG
233
203
{
234
204
 private:
415
385
};
416
386
 
417
387
 
418
 
/* type of the log table */
419
 
#define QUERY_LOG_SLOW 1
420
 
#define QUERY_LOG_GENERAL 2
421
 
 
422
 
class Log_to_file_event_handler: public Log_event_handler
423
 
{
424
 
  DRIZZLE_QUERY_LOG mysql_log;
425
 
  DRIZZLE_QUERY_LOG mysql_slow_log;
426
 
  bool is_initialized;
427
 
public:
428
 
  Log_to_file_event_handler(): is_initialized(false)
429
 
  {}
430
 
  virtual bool init();
431
 
  virtual void cleanup();
432
 
 
433
 
  virtual bool log_slow(THD *thd, time_t current_time,
434
 
                        time_t query_start_arg, const char *user_host,
435
 
                        uint user_host_len, uint64_t query_utime,
436
 
                        uint64_t lock_utime, bool is_command,
437
 
                        const char *sql_text, uint sql_text_len);
438
 
  virtual bool log_error(enum loglevel level, const char *format,
439
 
                         va_list args);
440
 
  virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
441
 
                           uint user_host_len, int thread_id,
442
 
                           const char *command_type, uint command_type_len,
443
 
                           const char *sql_text, uint sql_text_len,
444
 
                           const CHARSET_INFO * const client_cs);
445
 
  void flush();
446
 
  void init_pthread_objects();
447
 
  DRIZZLE_QUERY_LOG *get_mysql_slow_log() { return &mysql_slow_log; }
448
 
  DRIZZLE_QUERY_LOG *get_mysql_log() { return &mysql_log; }
449
 
};
450
 
 
451
 
 
452
388
/* Class which manages slow, general and error log event handlers */
453
389
class LOGGER
454
390
{
456
392
  /* flag to check whether logger mutex is initialized */
457
393
  uint inited;
458
394
 
459
 
  /* available log handlers */
460
 
  Log_to_file_event_handler *file_log_handler;
461
 
 
462
395
  /* NULL-terminated arrays of log handlers */
463
396
  Log_event_handler *error_log_handler_list[MAX_LOG_HANDLERS_NUM + 1];
464
397
  Log_event_handler *slow_log_handler_list[MAX_LOG_HANDLERS_NUM + 1];
466
399
 
467
400
public:
468
401
 
469
 
  LOGGER() : inited(0), file_log_handler(NULL)
 
402
  LOGGER() : inited(0)
470
403
  {}
471
404
  void lock_shared() { rw_rdlock(&LOCK_logger); }
472
405
  void lock_exclusive() { rw_wrlock(&LOCK_logger); }
495
428
                         const char *query, uint query_length);
496
429
 
497
430
  /* we use this function to setup all enabled log event handlers */
498
 
  int set_handlers(uint error_log_printer,
499
 
                   uint slow_log_printer,
500
 
                   uint general_log_printer);
 
431
  int set_handlers(uint error_log_printer);
501
432
  void init_error_log(uint error_log_printer);
502
 
  void init_slow_log(uint slow_log_printer);
503
 
  void init_general_log(uint general_log_printer);
504
433
  void deactivate_log_handler(THD* thd, uint log_type);
505
434
  bool activate_log_handler(THD* thd, uint log_type);
506
 
  DRIZZLE_QUERY_LOG *get_slow_log_file_handler()
507
 
  { 
508
 
    if (file_log_handler)
509
 
      return file_log_handler->get_mysql_slow_log();
510
 
    return NULL;
511
 
  }
512
 
  DRIZZLE_QUERY_LOG *get_log_file_handler()
513
 
  { 
514
 
    if (file_log_handler)
515
 
      return file_log_handler->get_mysql_log();
516
 
    return NULL;
517
 
  }
518
435
};
519
436
 
520
437
enum enum_binlog_format {