~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log.cc

  • Committer: Brian Aker
  • Date: 2008-11-26 02:45:41 UTC
  • mfrom: (623 drizzle)
  • mto: (612.2.8 devel)
  • mto: This revision was merged to the branch mainline in revision 624.
  • Revision ID: brian@gir-3.local-20081126024541-yy50s0800g7v0q1m
Merge tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3099
3099
  return;
3100
3100
}
3101
3101
 
3102
 
/**
3103
 
  Prints a printf style message to the error log and, under NT, to the
3104
 
  Windows event log.
3105
 
 
3106
 
  This function prints the message into a buffer and then sends that buffer
3107
 
  to other functions to write that message to other logging sources.
3108
 
 
3109
 
  @param event_type          Type of event to write (Error, Warning, or Info)
3110
 
  @param format              Printf style format of message
3111
 
  @param args                va_list list of arguments for the message
3112
 
 
3113
 
  @returns
3114
 
    The function always returns 0. The return value is present in the
3115
 
    signature to be compatible with other logging routines, which could
3116
 
    return an error (e.g. logging to the log tables)
3117
 
*/
3118
 
static void print_buffer_to_file(enum loglevel level, int,
3119
 
                                 const char *buffer, size_t)
3120
 
{
3121
 
  time_t skr;
3122
 
  struct tm tm_tmp;
3123
 
  struct tm *start;
3124
 
 
3125
 
  pthread_mutex_lock(&LOCK_error_log);
3126
 
 
3127
 
  skr= my_time(0);
3128
 
  localtime_r(&skr, &tm_tmp);
3129
 
  start=&tm_tmp;
3130
 
 
3131
 
  fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n",
3132
 
          start->tm_year % 100,
3133
 
          start->tm_mon+1,
3134
 
          start->tm_mday,
3135
 
          start->tm_hour,
3136
 
          start->tm_min,
3137
 
          start->tm_sec,
3138
 
          (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ?
3139
 
           "Warning" : "Note"),
3140
 
          buffer);
3141
 
 
3142
 
  fflush(stderr);
3143
 
 
3144
 
  pthread_mutex_unlock(&LOCK_error_log);
3145
 
  return;
3146
 
}
3147
 
 
3148
 
 
3149
 
int vprint_msg_to_log(enum loglevel level, const char *format, va_list args)
3150
 
{
3151
 
  char   buff[1024];
3152
 
  size_t length;
3153
 
  int error_code= errno;
3154
 
 
3155
 
  length= vsnprintf(buff, sizeof(buff), format, args);
3156
 
 
3157
 
  print_buffer_to_file(level, error_code, buff, length);
3158
 
 
3159
 
  return(0);
3160
 
}
3161
 
 
3162
 
 
3163
3102
void sql_print_error(const char *format, ...) 
3164
3103
{
3165
3104
  va_list args;