http_log.inc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. { Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {$ifdef HAVE_SYSLOG}
  17. //#include <syslog.h>
  18. APLOG_EMERG = LOG_EMERG; { system is unusable }
  19. APLOG_ALERT = LOG_ALERT; { action must be taken immediately }
  20. APLOG_CRIT = LOG_CRIT; { critical conditions }
  21. APLOG_ERR = LOG_ERR; { error conditions }
  22. APLOG_WARNING = LOG_WARNING; { warning conditions }
  23. APLOG_NOTICE = LOG_NOTICE; { normal but significant condition }
  24. APLOG_INFO = LOG_INFO; { informational }
  25. APLOG_DEBUG = LOG_DEBUG; { debug-level messages }
  26. APLOG_LEVELMASK= LOG_PRIMASK; { mask off the level value }
  27. {$else}
  28. APLOG_EMERG = 0; { system is unusable }
  29. APLOG_ALERT = 1; { action must be taken immediately }
  30. APLOG_CRIT = 2; { critical conditions }
  31. APLOG_ERR = 3; { error conditions }
  32. APLOG_WARNING = 4; { warning conditions }
  33. APLOG_NOTICE = 5; { normal but significant condition }
  34. APLOG_INFO = 6; { informational }
  35. APLOG_DEBUG = 7; { debug-level messages }
  36. APLOG_LEVELMASK= 7; { mask off the level value }
  37. {$endif}
  38. APLOG_NOERRNO = (APLOG_LEVELMASK + 1);
  39. {$ifdef WINDOWS}
  40. { Set to indicate that error msg should come from Win32's GetLastError(),
  41. * not errno. }
  42. APLOG_WIN32ERROR = ((APLOG_LEVELMASK + 1) * 2);
  43. {$endif}
  44. DEFAULT_LOGLEVEL = APLOG_WARNING;
  45. //#define APLOG_MARK __FILE__,__LINE__
  46. procedure ap_open_logs(s: Pserver_rec; p: PPool);
  47. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  48. { The two primary logging functions, ap_log_error and ap_log_rerror,
  49. * use a printf style format string to build the log message. It is
  50. * VERY IMPORTANT that you not include any raw data from the network,
  51. * such as the request-URI or request header fields, within the format
  52. * string. Doing so makes the server vulnerable to a denial-of-service
  53. * attack and other messy behavior. Instead, use a simple format string
  54. * like "%s", followed by the string containing the untrusted data.
  55. }
  56. procedure ap_log_error(
  57. const file_: PChar; line, level: Integer;
  58. const s: Pserver_rec; const fmt: PChar; others: array of const);
  59. cdecl; external LibHTTPD;
  60. // __attribute__((format(printf,5,6)));
  61. procedure ap_log_rerror(
  62. const file_: PChar; line, level: Integer;
  63. const s: Prequest_rec; const fmt: PChar; others: array of const);
  64. cdecl; external LibHTTPD;
  65. // __attribute__((format(printf,5,6)));
  66. procedure ap_error_log2stderr(s: Pserver_rec);
  67. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  68. procedure ap_log_pid(p: PPool; fname: PChar);
  69. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  70. { These are for legacy code, new code should use ap_log_error,
  71. * or ap_log_rerror.
  72. }
  73. {API_EXPORT(void) ap_log_error_old(const char *err, server_rec *s);
  74. API_EXPORT(void) ap_log_unixerr(const char *routine, const char *file,
  75. const char *msg, server_rec *s);
  76. API_EXPORT_NONSTD(void) ap_log_printf(const server_rec *s, const char *fmt, ...)
  77. __attribute__((format(printf,2,3)));
  78. API_EXPORT(void) ap_log_reason(const char *reason, const char *fname,
  79. request_rec *r);}
  80. type
  81. piped_log = record
  82. p: PPool;
  83. //#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF)
  84. program_: PChar;
  85. pid: cint;
  86. fds: array[1..2] of cint;
  87. //#else
  88. // FILE *write_f;
  89. //#endif
  90. end;
  91. Ppiped_log = ^piped_log;
  92. procedure ap_open_piped_log(p: PPool; const program_: PChar);
  93. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  94. function ap_close_piped_log(p: Ppiped_log): Ppiped_log;
  95. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  96. {#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF)
  97. #define ap_piped_log_read_fd(pl) ((pl)->fds[0])
  98. #define ap_piped_log_write_fd(pl) ((pl)->fds[1])
  99. #else}
  100. //#define ap_piped_log_read_fd(pl) (-1)
  101. //#define ap_piped_log_write_fd(pl) (fileno((pl)->write_f))
  102. //#endif