UNPKG

@mdfriday/foundry

Version:

The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.

59 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HTTPErrorLogger = void 0; exports.NewHTTPErrorLogger = NewHTTPErrorLogger; class HTTPErrorLogger { constructor(logger) { this.logger = logger; } /** * Process HTTP error messages and log them appropriately * Similar to Go's httpErrorLog.Write method */ write(message) { const trimmedMessage = message.trim(); // Handle specific HTTP error patterns (similar to Go implementation) if (trimmedMessage.includes('http: URL query contains semicolon')) { this.logger.debug(trimmedMessage); } else { this.logger.error(trimmedMessage); } } /** * Create a write stream compatible function for HTTP servers * This can be used with HTTP server error handlers */ getWriteFunction() { return (message) => this.write(message); } /** * Create a Node.js compatible writable stream interface * This allows the logger to be used where a writable stream is expected */ createWritableStream() { const self = this; const { Writable } = require('stream'); return new Writable({ write(chunk, encoding, callback) { try { const message = chunk.toString(); self.write(message); callback(); } catch (error) { callback(error); } } }); } } exports.HTTPErrorLogger = HTTPErrorLogger; /** * Create a new HTTP error logger * Similar to Go's NewHTTPErrorLog function */ function NewHTTPErrorLogger(logger) { return new HTTPErrorLogger(logger); } //# sourceMappingURL=http.js.map