*`Identity` is the `SignedUserName` or `"-"` if the user is not logged
in
*`Start` is the start time of the request
*`ResponseWriter` is the `macaron.ResponseWriter`
Caution must be taken when changing this template as it runs outside of
the standard panic recovery trap. The template should also be as simple
as it runs for every request.
### The "XORM" logger
The XORM logger is a long-standing logger that exists to collect XORM
log events. It is enabled by default but can be switched off by setting
`ENABLE_XORM_LOG` to `false` in the `[log]` section. Its outputs are
configured by setting the `XORM` value in the `[log]` section of the
configuration. `XORM` defaults to `,` if unset, meaning it is redirected
to the main Gitea log.
XORM will log SQL events by default. This can be changed by setting
the `LOG_SQL` value to `false` in the `[database]` section.
Each output sublogger for this logger is configured in
`[log.sublogger.xorm]` sections. There are certain default values
which will not be inherited from the `[log]` or relevant
`[log.sublogger]` sections:
*`FILE_NAME` will default to `%(ROOT_PATH)/xorm.log`
*`FLAGS` defaults to `date,time`
*`EXPRESSION` will default to `""`
*`PREFIX` will default to `""`
### The Hook and Serv "GitLoggers"
These are less well defined loggers. Essentially these should only be
used within Gitea's subsystems and cannot be configured at present.
They will write log files in:
*`%(ROOT_PATH)/hooks/pre-receive.log`
*`%(ROOT_PATH)/hooks/update.log`
*`%(ROOT_PATH)/hooks/post-receive.log`
*`%(ROOT_PATH)/serv.log`
*`%(ROOT_PATH)/http.log`
In the future these logs may be rationalised.
## Log outputs
Gitea provides 4 possible log outputs:
*`console` - Log to `os.Stdout` or `os.Stderr`
*`file` - Log to a file
*`conn` - Log to a keep-alive TCP connection
*`smtp` - Log via email
Certain configuration is common to all modes of log output:
*`LEVEL` is the lowest level that this output will log. This value
is inherited from `[log]` and in the case of the non-default loggers
from `[log.sublogger]`.
*`STACKTRACE_LEVEL` is the lowest level that this output will print
a stacktrace. This value is inherited.
*`MODE` is the mode of the log output. It will default to the sublogger
name. Thus `[log.console.macaron]` will default to `MODE = console`.
*`COLORIZE` will default to `true` for `file` and `console` as
described, otherwise it will default to `false`.
### Non-inherited default values
There are several values which are not inherited as described above but
rather default to those specific to type of logger, these are:
`EXPRESSION`, `FLAGS`, `PREFIX` and `FILE_NAME`.
#### `EXPRESSION`
`EXPRESSION` represents a regular expression that log events must match to be logged by the sublogger. Either the log message, (with colors removed), must match or the `longfilename:linenumber:functionname` must match. NB: the whole message or string doesn't need to completely match.
Please note this expression will be run in the sublogger's goroutine
not the logging event subroutine. Therefore it can be complicated.
#### `FLAGS`
`FLAGS` represents the preceding logging context information that is
printed before each message. It is a comma-separated string set. The order of values does not matter.
Possible values are:
*`none` or `,` - No flags.
*`date` - the date in the local time zone: `2009/01/23`.
*`time` - the time in the local time zone: `01:23:23`.
Structs may implement the `log.ColorFormatted` interface by implementing the `ColorFormat(fmt.State)` function.
If a `log.ColorFormatted` struct is logged with `%-v` format, its `ColorFormat` will be used instead of the usual `%v`. The full `fmt.State` will be passed to allow implementers to look at additional flags.
In order to help implementers provide `ColorFormat` methods. There is a
`log.ColorFprintf(...)` function in the log module that will wrap values in `log.ColoredValue` and recognise `%-v`.
In general it is recommended not to make the results of this function too verbose to help increase its versatility. Usually this should simply be an `ID`:`Name`. If you wish to make a more verbose result, it is recommended to use `%-+v` as your marker.