TykTechnologies / tyk

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Other
9.76k stars 1.09k forks source link

Revert "Merging to release-5.3: [TT-12355] added log format config, func and test cases (#6344)" #6485

Closed titpetric closed 2 months ago

titpetric commented 2 months ago

User description

Reverts TykTechnologies/tyk#6484


PR Type

enhancement, bug fix


Description


Changes walkthrough 📝

Relevant files
Enhancement
config.go
Remove LogFormat configuration option                                       

config/config.go - Removed the `LogFormat` configuration option.
+0/-4     
server.go
Refactor and rename initialization functions                         

gateway/server.go
  • Renamed initRPCCache to InitializeRPCCache.
  • Renamed initSystem to initialiseSystem.
  • Removed log format initialization.
  • +21/-31 
    testutil.go
    Update test setup function name                                                   

    gateway/testutil.go - Renamed `initSystem` to `initialiseSystem` in test setup.
    +1/-1     
    log.go
    Simplify log formatter setup and remove JSONFormatter       

    log/log.go
  • Removed JSONFormatter and related functionality.
  • Simplified log formatter setup.
  • +43/-59 
    Configuration changes
    schema.json
    Remove log_format option from schema                                         

    cli/linter/schema.json - Removed `log_format` configuration option from schema.
    +0/-4     
    Dependencies
    go.mod
    Remove go-json dependency                                                               

    go.mod - Removed dependency on `github.com/goccy/go-json`.
    +0/-1     
    go.sum
    Remove go-json checksums                                                                 

    go.sum - Removed checksums for `github.com/goccy/go-json`.
    +0/-2     

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    github-actions[bot] commented 2 months ago

    API Changes

    --- prev.txt    2024-09-05 13:48:42.156647569 +0000
    +++ current.txt 2024-09-05 13:48:38.888660046 +0000
    @@ -5247,10 +5247,6 @@
        // If not set or left empty, it will default to `info`.
        LogLevel string `json:"log_level"`
    
    -   // You can now configure the log format to be either the standard or json format
    -   // If not set or left empty, it will default to `standard`.
    -   LogFormat string `json:"log_format"`
    -
        // Section for configuring OpenTracing support
        // Deprecated: use OpenTelemetry instead.
        Tracer Tracer `json:"tracing"`
    @@ -8125,6 +8121,8 @@
    
     func (gw *Gateway) InitHostCheckManager(ctx context.Context, store storage.Handler)
    
    +func (gw *Gateway) InitializeRPCCache()
    +
     func (gw *Gateway) LoadAPI(specs ...*APISpec) (out []*APISpec)
    
     func (gw *Gateway) LoadDefinitionsFromRPCBackup() ([]*APISpec, error)
    @@ -10408,57 +10406,25 @@
     FUNCTIONS
    
     func Get() *logrus.Logger
    -    Get returns the default configured logger.
    -
     func GetRaw() *logrus.Logger
    -    GetRaw is used internally. Should likely be removed first, do not rely on
    -    it.
    -
     func LoadTranslations(thing map[string]interface{})
         LoadTranslations takes a map[string]interface and flattens it to
    -    map[string]string. Because translations have been loaded - we internally
    -    override log the formatter. Nested entries are accessible using dot
    -    notation.
    -
    -    Example: `{"foo": {"bar": "baz"}}` Flattened: `foo.bar: baz`
    +    map[string]string Because translations have been loaded - we internally
    +    override log the formatter Nested entries are accessible using dot notation.
    +    example: `{"foo": {"bar": "baz"}}` flattened: `foo.bar: baz`
    
    -func NewFormatter(format string) logrus.Formatter
    
     TYPES
    
    -type JSONFormatter struct {
    -   // TimestampFormat sets the format used for marshaling timestamps.
    -   // The format to use is the same than for time.Format or time.Parse from the standard
    -   // library.
    -   // The standard Library already provides a set of predefined format.
    -   TimestampFormat string
    -
    -   // DisableTimestamp allows disabling automatic timestamps in output.
    -   DisableTimestamp bool
    -
    -   // DataKey allows users to put all the log entry parameters into a nested dictionary at a given key.
    -   DataKey string
    -}
    -    JSONFormatter formats logs into parsable json.
    -
    -func (f *JSONFormatter) Format(entry *logrus.Entry) ([]byte, error)
    -    Format renders a single log entry
    -
     type RawFormatter struct{}
    -    RawFormatter returns the logrus entry message as bytes.
    
     func (f *RawFormatter) Format(entry *logrus.Entry) ([]byte, error)
    -    Format returns the entry.Message as a []byte.
    
     type TranslationFormatter struct {
    -   logrus.Formatter
    +   *logrus.TextFormatter
     }
    -    TranslationFormatter handles message reformatting with translations.
    
     func (t *TranslationFormatter) Format(entry *logrus.Entry) ([]byte, error)
    -    Format will translate the log message based on the message code. This is a
    -    HTTP response code if provided. The message is usually just "Finished" for
    -    those cases, this would likely produce a better log message.
    
     # Package: ./regexp
    
    github-actions[bot] commented 2 months ago

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Function Renaming
    The renaming of `initRPCCache` to `InitializeRPCCache` and `initSystem` to `initialiseSystem` may impact existing references or documentation that need to be updated to reflect these changes. Major Refactoring
    Significant changes in logging functionality, including removal of JSON formatter and introduction of new formatter logic, could affect how logs are processed and displayed. This needs thorough testing to ensure compatibility and correctness.
    github-actions[bot] commented 2 months ago

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    sonarcloud[bot] commented 2 months ago

    Quality Gate Failed Quality Gate failed

    Failed conditions
    43.8% Coverage on New Code (required ≥ 80%)
    C Reliability Rating on New Code (required ≥ A)

    See analysis details on SonarCloud

    Catch issues before they fail your Quality Gate with our IDE extension SonarLint