Ghobad
c6ae2e6966
feat(logger): ability to skip logs based on user-defined logic ( #3593 )
...
* log skipper
* do not call time.now() if logging should be skipped
* do not ignore skip func delay in latency calculation
* write docs
* write test
2024-02-02 09:52:26 +08:00
Viral Parmar
a481ee2897
chore(http): use white color for HTTP 1XX ( #3741 )
2023-09-27 15:17:11 +08:00
hopehook
b2d4185eec
Replace bytes.Buffer with strings.Builder where appropriate ( #3347 )
...
To build strings more efficiently, use strings.Builder instead.
2023-01-20 09:51:42 +08:00
thinkerou
b04917c53e
chore: upgrade golangci-lint and fix golangci-lint error ( #3278 )
2022-08-15 21:38:20 +08:00
thinkerou
4b68a5f12a
chore: update go.mod and remove space from copyright ( #3158 )
...
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-28 10:42:28 +08:00
mstmdev
444e156fb1
Fix some tests ( #3100 )
...
* Sleep for one millisecond in the handler because the `Latency` will return `0s` sometimes and the test will fail
* The `TCPListener.File` is not supported by windows, it is unimplemented now
* Remove the `LF` in the `testdata/template/raw.tmpl`, because if set the git config `core.autocrlf=true`, will append `CR` to the raw.tmpl automatically, then test is failed on Windows
2022-04-21 18:21:46 +08:00
thinkerou
2bde107686
test support go1.18 ( #2990 )
2022-03-21 09:43:17 +08:00
Bo-Yi Wu
94153d1e19
test: expose performRequest func ( #3012 )
2022-01-02 19:07:44 +08:00
Xudong Cai
03e5e05ae0
fix: data race with trustedCIDRs ( #2674 ) ( #2675 )
...
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-04-09 00:27:34 +08:00
Manuel Alonso
a71af9c144
removing log injection ( #2277 )
...
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-03-07 21:51:33 +08:00
Kaushik Neelichetty
5f56109bcf
Use json marshall in context json to fix breaking new line issue. Fixes #2209 ( #2228 )
...
* ignore IntelliJ idea generated files
* update JSON renderer to use Marshall() instead of Encode(). Fix #2209
* Revert "ignore IntelliJ idea generated files"
This reverts commit e7bd017227
.
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-02-21 17:15:17 +08:00
Shuo
a22377b09b
logger_test: color ( #1926 )
...
* logger color: string literals
* logger_test: color
2019-08-29 08:32:22 +08:00
itcloudy
0cbf290302
use encode replace json marshal increase json encoder speed ( #1546 )
2019-05-22 07:48:50 +08:00
Dan Markham
ce20f107f5
Truncate Latency precision in long running request ( #1830 )
...
fixes #1823
2019-03-28 14:14:00 +08:00
Sai
b40d4c175c
IsTerm flag should not be affected by DisableConsoleColor method. ( #1802 )
...
* IsTerm flag should not be affected by DisableConsoleColor method.
* change public property to private
2019-03-18 11:12:30 +08:00
Sai
f7079a861e
Delete dupilicated test ( #1801 )
2019-03-08 19:44:39 +08:00
Adam Zielinski
3dc247893e
make context.Keys available as LogFormatterParams ( #1779 )
...
* make context available as LogFormatterParams
* pass context Keys to LogFormatterParams
* update logger test to check for Key param
2019-03-07 09:47:31 +08:00
Sai
e6288e90eb
Change color methods in using defaultLogger function to public ( #1771 )
...
Fix https://github.com/gin-gonic/gin/issues/1768
2019-02-22 16:48:55 +08:00
Olivier Robardet
a58a2f9bf3
Add a function to force color in console output ( #1724 )
...
Add a function `ForceConsoleColor`, like `DisableConsoleColor` but to force coloring the output.
It usefull when some IDE's integrated console (like IntelliJ or Goland) are not detected as TTY, but can display colors.
Also helps if one want to output color in log file (#1590 ) and as a workaround for #1547 .
2019-02-20 21:14:16 +08:00
Dmitry Kutakov
b056a34bdc
fix errcheck warnings ( #1739 )
2019-01-18 09:32:53 +08:00
Sai
678e09c736
Plural is "Paths", not "Pathes" ( #1706 )
2018-12-20 17:54:08 +08:00
Sai
f76ccb25f1
Add LoggerWithFormatter method ( #1677 )
...
* Add LoggerWithFormatter
* Add tests for LoggerWithFormatter & LoggerWithConfig
* Add note for README
* Add tests for DefaultLogFormatter
* Add comment
* Change DefaultLogFormatter to a private method
2018-12-12 09:05:16 +08:00
andrea
fd599fccea
Make logger use a yellow background and a darkgray text for legibility ( #1570 )
...
1. Why is this change neccesary?
White text on a yellow background was illegible with most terminal color schemes
2. How does it address the issue?
The white text was replaced with a bash compatible dark gray while keeping the
yellow background colour
3. What side effects does this change have?
Resolves #1552
2018-09-26 10:28:25 +08:00
田欧
f45c928a15
chore: use http.Status* instead of hard code ( #1482 )
2018-08-14 09:51:56 +08:00
田欧
eeb57848ca
update assert param(expect, actual) position ( #1177 )
2017-11-21 21:18:45 +08:00
Bo-Yi Wu
e31cbdf241
feat(logger): show query string in logger. ( #999 ) close #988
...
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-07-10 10:41:20 +02:00
cssivision
f4dec22c50
fix: buffer should reset when test logger output ( #819 )
2017-02-28 15:15:52 +08:00
Bo-Yi Wu
d158ef2e82
Support disable console color.
...
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-21 14:41:47 +08:00
Bo-Yi Wu
787bff85e5
fix testing.
...
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-11 10:14:23 +08:00
Roy Lou
4c4444b160
Write header immediately in AbortWithStatus()
...
Otherwise, caller needs to invoke WriteHeaderNow himself after
AbortWithStatus(), which is error-prone.
Also modified ErrorLoggerT() such that it always writes log to response
body. Otherwise calling AbortWithStatus() will fail to write body because
c.Writer.Written() is set true by WriteHeaderNow().
2016-04-15 00:02:29 +08:00
Manu Mtz.-Almeida
e9531e5c76
Merge branch 'master' into develop
2016-01-26 20:08:28 +01:00
shadrus
13ba260d76
Wrong copy/paste TODO
2015-10-05 22:27:03 +03:00
Roman Zaynetdinov
f13c3ae898
Add option to skip logging specified endpoints
2015-07-22 17:02:36 +03:00
Manu Mtz-Almeida
c9272120b4
Adds unit tests for ErrorLogger()
2015-07-04 20:15:15 +02:00
Kevin Mulvey
7469025182
forgot the default of ColorForMethod
2015-05-27 20:53:28 -04:00
Kevin Mulvey
1b031cb271
Added tests for colorForMethod() and colorForStatus()
2015-05-27 20:36:37 -04:00
Manu Mtz-Almeida
99694bb716
Fixes errors
2015-05-12 15:22:13 +02:00
Manu Mtz-Almeida
0a192fb0fa
Tons of unit tests
2015-04-09 12:15:02 +02:00