Documentation ¶
Overview ¶
Copyright © 2019, 2022 M.Watermann, 10247 Berlin, Germany All rights reserved EMail : <support@mwat.de>
Package apachelogger implements a logger middleware for Go web-servers.
Copyright © 2019, 2022 M.Watermann, 10247 Berlin, Germany All rights reserved EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // AnonymiseURLs decides whether to anonymise the remote IP addresses // before writing them to the logfile (default: `true`). // // For privacy and legal reasons this variable should always // stay `true`. AnonymiseURLs = true // AnonymiseErrors decides whether to anonymise remote IP addresses // that cause errors with our server using this module. AnonymiseErrors = false )
Functions ¶
func Err ¶
func Err(aSender, aMessage string)
Err writes `aMessage` on behalf of `aSender` to the error logfile.
`aSender` The name/designation of the sending entity. `aMessage` The text to write to the error logfile.
func Log ¶
func Log(aSender, aMessage string)
Log writes `aMessage` on behalf of `aSender` to the access logfile.
`aSender` The name/designation of the sending entity. `aMessage` The text to write to the access logfile.
func SetErrLog ¶
SetErrLog sets the error logger of `aServer`.
`aServer` The server instance whose errlogger is to be set.
func Wrap ¶
Wrap returns a handler function that includes logging, wrapping the given `aHandler`, and calling it internally.
The logfile entries written to `aAccessLog` resemble the combined log file messages generated by the Apache web-server.
In case the provided `aAccessLog` can't be opened `Wrap()` terminates the program with an appropriate error-message.
`aHandler` responds to the actual HTTP request. `aAccessLog` is the name of the file to use for access log messages. `aErrorLog` is the name of the file to use for error log messages.
The function returns the (augmented) `http.Handler`.
Types ¶
This section is empty.