fiber/middleware
Edvard e947e03ed2
🔥 feat(logger): Add predefined log formats (#3359)
* feat(logger): Add predefined log formats

This commit introduces predefined log formats for the logger middleware, enhancing its flexibility and ease of use. Users can now specify formats like "common", "combined", and "json" in addition to the default format.

Changes:

- Added a `format.go` file to store predefined log format constants.
- Updated `config.go` to include documentation for the `Format` configuration option, explaining the available placeholders and predefined formats.
- Modified `logger.go` to utilize the predefined formats based on the `Format` configuration.
- Added a new test case `Test_Logger_CLF` in `logger_test.go` to verify the "common" log format.

* feat(logger): Use predefined formats and fix default format

This commit updates the logger middleware to utilize the predefined log formats introduced in a previous commit. It also fixes the default format to use the `FormatDefault` constant.

Changes:

-   Updated `config.go` to use `FormatDefault` constant for the default format.
-   Updated `default_logger.go` to use `FormatDefault` constant for the default format.
-   Added new test cases in `logger_test.go` to verify the "common", "combined" and "json" log formats.
-   Updated `format.go` to add newline character to the end of the default format.

* feat(logger): Document and exemplify predefined formats

* fix(logger): Improve test assertions based on golangci-lint

* docs(logger): Improve documentation and formatting logger.md based on markdownlint-cli2

* docs(logger): Improve documentation based on markdownlint-cli2

* fix(logger): Improve combined and JSON format tests

* feat(logger): Add ECS log format

* feat(logger): Add CustomFormat option

This commit introduces a `CustomFormat` option to the `Config` struct, allowing users to specify a predefined format (like "common", "combined", "json", or "ecs")

* feat(logger): Add ECS log format to examples and config

* docs(logger): Update examples in whats_new.md

* feat(logger): Remove CustomFormat option and renamed Format consts

-   Removed `CustomFormat` field from `Config`.
-   Removed `LoggerConfig` map.
-   Rename predefined formats constants.

* docs(logger): Update documentation and examples after format refactor

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-03-21 16:13:21 +01:00
..
adaptor 🧹 chore: Fix linter workflow failures (#3354) 2025-03-17 08:29:51 +01:00
basicauth v3: Use Named Fields Instead of Positional and Align Structures to Reduce Memory Usage (#3079) 2024-07-23 08:37:45 +02:00
cache ♻️ Refactor: Reduce the Memory Usage of ignoreHeaders (#3322) 2025-02-24 08:12:47 +01:00
compress 🔥 Feature: Add TestConfig to app.Test() for configurable testing (#3161) 2024-11-22 08:43:38 +01:00
cors 🔥Feature: Add support for TrustProxy (#3170) 2024-10-17 08:29:03 +02:00
csrf 🧹 chore: Mark unused tests with t.SkipNow (#3366) 2025-03-20 14:35:59 +01:00
earlydata 🔥Feature: Add support for TrustProxy (#3170) 2024-10-17 08:29:03 +02:00
encryptcookie chore: Bump golangci-lint to v1.60.3 (#3119) 2024-09-02 15:38:59 +02:00
envvar v3: Use Named Fields Instead of Positional and Align Structures to Reduce Memory Usage (#3079) 2024-07-23 08:37:45 +02:00
etag 🐛 fix: Improve naming convention for Context returning functions (#3193) 2024-11-13 16:12:19 +01:00
expvar 🐛 fix: Improve naming convention for Context returning functions (#3193) 2024-11-13 16:12:19 +01:00
favicon v3: Use Named Fields Instead of Positional and Align Structures to Reduce Memory Usage (#3079) 2024-07-23 08:37:45 +02:00
healthcheck feat: Add Startup Probe to Healthcheck Middleware (#3069) 2024-07-18 13:54:44 +02:00
helmet fix: default value comment 2025-03-13 01:44:57 +08:00
idempotency 🩹 Fix: Memory leak removal in the idempotency middleware (#3263) 2024-12-28 14:29:31 +01:00
keyauth 🔥 feat: Add support for context.Context in keyauth middleware (#3287) 2025-03-07 08:23:24 +01:00
limiter Bump golangci-lint to v1.62.0 (#3196) 2024-11-11 10:37:27 +01:00
logger 🔥 feat(logger): Add predefined log formats (#3359) 2025-03-21 16:13:21 +01:00
pprof 🔥 Feature: Add TestConfig to app.Test() for configurable testing (#3161) 2024-11-22 08:43:38 +01:00
proxy 🧹 chore: Fix linter workflow failures (#3354) 2025-03-17 08:29:51 +01:00
recover v3: Use Named Fields Instead of Positional and Align Structures to Reduce Memory Usage (#3079) 2024-07-23 08:37:45 +02:00
redirect 🐛 fix: Improve naming convention for Context returning functions (#3193) 2024-11-13 16:12:19 +01:00
requestid 🔥 feat: Add Context Support to RequestID Middleware (#3200) 2024-11-15 17:34:20 +01:00
rewrite v3: Add Benchmarks for Rewrite Middleware (#3092) 2024-07-26 16:55:00 +02:00
session build(deps): bump github.com/valyala/fasthttp from 1.57.0 to 1.58.0 (#3244) 2024-12-16 09:03:57 +01:00
skip Merge remote-tracking branch 'origin/master' into v3-beta 2023-08-05 22:02:01 +03:00
static Add new config option 2025-02-23 16:00:39 -05:00
timeout refactor(timeout): unify and enhance timeout middleware (#3275) 2025-01-08 08:19:20 +01:00