diff options
author | zeripath <art27@cantab.net> | 2019-04-22 21:40:51 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-04-22 23:40:51 +0300 |
commit | be666b03eef1e085adc0749837480e0db7f811ad (patch) | |
tree | ed8f4bc7c4a5cf2c7a7a37e38aef23b10a83595e /docs | |
parent | b83114f1407247415b184f77f8f2f6ecea8cb994 (diff) | |
download | gitea-be666b03eef1e085adc0749837480e0db7f811ad.tar.gz gitea-be666b03eef1e085adc0749837480e0db7f811ad.zip |
Trace Logging on Permission Denied & ColorFormat (#6618)
* Add log.ColorFormat and log.ColorFormatted
Structs can now implement log.ColorFormatted to provide their own
colored format when logged with `%-v` or additional flags.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add basic ColorFormat to repository and user
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add basic ColorFormat to access and unit
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add ColorFormat to permission and on trace log it
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add log.NewColoredIDValue to make ID value coloring consistent
Signed-off-by: Andrew Thornton <art27@cantab.net>
* formatting changes
* Add some better tracing to permission denied for read issues/pulls
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add Trace logging on permission denied
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove isTrace() check from deferred func
* Adjust repo and allow logging of team
* use FormatInt instead of Itoa
* Add blank line
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update access.go
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content/doc/advanced/logging-documentation.en-us.md | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/docs/content/doc/advanced/logging-documentation.en-us.md b/docs/content/doc/advanced/logging-documentation.en-us.md index bef034e2e7..3af75c0d8f 100644 --- a/docs/content/doc/advanced/logging-documentation.en-us.md +++ b/docs/content/doc/advanced/logging-documentation.en-us.md @@ -362,6 +362,17 @@ also set the `resetBytes` to the cached `resetBytes`. The `colorBytes` and `resetBytes` are not exported to prevent accidental overwriting of internal values. +## ColorFormat & ColorFormatted + +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. + ## Log Spoofing protection In order to protect the logs from being spoofed with cleverly @@ -392,5 +403,5 @@ func newNewoneLogService() { } ``` -You should then add `newOneLogService` to `NewServices()` in +You should then add `newOneLogService` to `NewServices()` in `modules/setting/setting.go` |