-: 0:Source:modperl_log.c -: 0:Object:modperl_log.bb -: 1:/* Copyright 2000-2004 The Apache Software Foundation -: 2: * -: 3: * Licensed under the Apache License, Version 2.0 (the "License"); -: 4: * you may not use this file except in compliance with the License. -: 5: * You may obtain a copy of the License at -: 6: * -: 7: * http://www.apache.org/licenses/LICENSE-2.0 -: 8: * -: 9: * Unless required by applicable law or agreed to in writing, software -: 10: * distributed under the License is distributed on an "AS IS" BASIS, -: 11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -: 12: * See the License for the specific language governing permissions and -: 13: * limitations under the License. -: 14: */ -: 15: -: 16:#include "modperl_apache_includes.h" -: 17:#include "apr_lib.h" -: 18:#include "modperl_trace.h" -: 19:#include "modperl_log.h" -: 20: -: 21:#undef getenv /* from XSUB.h */ -: 22: -: 23:static apr_file_t *logfile = NULL; -: 24: -: 25:#ifdef WIN32 -: 26:static unsigned long debug_level = 0; -: 27:#else -: 28:unsigned long MP_debug_level = 0; -: 29:#define debug_level MP_debug_level -: 30:#endif -: 31: -: 32:unsigned long modperl_debug_level(void) #####: 33:{ #####: 34: return debug_level; -: 35:} -: 36: -: 37:void modperl_trace_logfile_set(apr_file_t *logfile_new) 8: 38:{ 8: 39: logfile = logfile_new; -: 40:} -: 41: -: 42:void modperl_trace(const char *func, const char *fmt, ...) #####: 43:{ #####: 44: char vstr[8192]; #####: 45: apr_size_t vstr_len = 0; #####: 46: va_list args; -: 47: #####: 48: if (!logfile) { #####: 49: return; -: 50: } -: 51: #####: 52: if (func) { #####: 53: apr_file_printf(logfile, "%s: ", func); -: 54: } -: 55: #####: 56: va_start(args, fmt); #####: 57: vstr_len = apr_vsnprintf(vstr, sizeof(vstr), fmt, args); #####: 58: va_end(args); -: 59: #####: 60: apr_file_write(logfile, vstr, &vstr_len); #####: 61: apr_file_printf(logfile, "\n"); -: 62:} -: 63: -: 64:void modperl_trace_level_set(server_rec *s, const char *level) 10: 65:{ 10: 66: if (!level) { 10: 67: if (!(level = getenv("MOD_PERL_TRACE"))) { #####: 68: return; -: 69: } -: 70: } #####: 71: debug_level = 0x0; -: 72: #####: 73: if (strcasecmp(level, "all") == 0) { #####: 74: debug_level = 0xffffffff; -: 75: } #####: 76: else if (apr_isalpha(level[0])) { #####: 77: static char debopts[] = MP_TRACE_OPTS; #####: 78: char *d; -: 79: #####: 80: for (; *level && (d = strchr(debopts, *level)); level++) { #####: 81: debug_level |= 1 << (d - debopts); -: 82: } -: 83: } -: 84: else { #####: 85: debug_level = atoi(level); -: 86: } -: 87: #####: 88: debug_level |= 0x80000000; -: 89: #####: 90: modperl_trace_logfile_set(s->error_log); -: 91: #####: 92: MP_TRACE_any_do(MP_TRACE_dump_flags()); -: 93:}