8000 feat: Add some chain calls for Log facade by kkumar-gcc · Pull Request #276 · goravel/framework · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add some chain calls for Log facade #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to 8000 your account

Merged
merged 26 commits into from
Sep 3, 2023
Merged

Conversation

kkumar-gcc
Copy link
Member
@kkumar-gcc kkumar-gcc commented Aug 28, 2023

Closes goravel/goravel#240

📑 Description

This pull request introduces a set of chainable function calls to enhance the capabilities of the Log facade. These new functions enable more efficient and expressive logging configuration and customization, making it easier to attach relevant information to log entries. The added methods include:

  • User: Associates a user with the log entry.
  • Owner: Specifies the responsible colleague or team for handling the logged error, aiding in alerting workflows.
  • Hint: Provides a hint that can expedite debugging processes.
  • Code: Set a code or slug that describes the error
  • With: Appends key-value pairs to the log entry's contextual information
  • Tags: Adds tags to categorize and group log entries
  • Request: Links an HTTP request to the log entry.
  • Response: Associates an HTTP response with the log entry.
  • In: Sets the feature category or domain in which the log entry is relevant
//example
facades.Log().
        User("kkumar-gcc").
        Owner("team@goravel.dev").
	Hint("Check the database connection.").
	Code("500").
	With(map[string]interface{}{"key1": "value1", "key2": "value2"}).
        Tags([]string{"error", "critical"}).
	In("backend").
        Errorf("Goravel: %s", "World")

//output(in log file)
[2023-08-28 15:56:15] test.error: Goravel: World {"error":{"message":"Goravel: World","tags":["error","critical"],"hint":"Check the database connection.","user":"john.doe","code":"500","domain":"backend","context":{"key1":"value1","key2":"value2"},"owner":"team@example.com","stacktrace":"Goravel: World\n\tsuite.(*Suite).Run.func2:/home/krish/go/pkg/mod/github.com/stretchr/testify@v1.8.4/suite/suite.go:112\n\tlog.(*LogrusTestSuite).TestLogrus.func26:/home/krish/goravel/framework/log/logrus_writer_test.go:246\n\tlog.(*LogrusTestSuite).TestLogrus.func20:/home/krish/goravel/framework/log/logrus_writer_test.go:200\n\tlog.(*Writer).Errorf:/home/krish/goravel/framework/log/logrus_writer.go:107\n\tlog.(*Writer).withStackTrace:/home/krish/goravel/framework/log/logrus_writer.go:198"}}

image
image

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

@kkumar-gcc kkumar-gcc changed the title [Feature] Add some chain calls for Log facade [Feat] Add some chain calls for Log facade Aug 28, 2023
Copy link
Contributor
@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, could you please add some screenshots for this feature?

@kkumar-gcc kkumar-gcc changed the title [Feat] Add some chain calls for Log facade [feat] Add some chain calls for Log facade Aug 28, 2023
@kkumar-gcc kkumar-gcc changed the title [feat] Add some chain calls for Log facade feat: Add some chain calls for Log facade Aug 28, 2023
@codecov
Copy link
codecov bot commented Aug 28, 2023

Codecov Report

Patch coverage is 86.95% of modified lines.

Files Changed Coverage
log/formatter/general.go 69.01%
log/logrus_writer.go 96.32%

📢 Thoughts on this report? Let us know!.

Copy link
Contributor
@hwbrzzl hwbrzzl left a comment
8000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A great PR

@kkumar-gcc kkumar-gcc requested a review from hwbrzzl August 31, 2023 05:00
Copy link
Contributor
@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! please add some test cases.

Copy link
Contributor
@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good

Copy link
Contributor
@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a big improvement, Bro.

Comment on lines 93 to 95
if testing.Short() {
t.Skip("Skipping tests of using docker")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: This judgment is only used in the Windows system, this is unnecessary if this case can be tested in Windows. The same as below.

Copy link
Contributor
@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@kkumar-gcc kkumar-gcc merged commit b665d1d into master Sep 3, 2023
@kkumar-gcc kkumar-gcc deleted the kkumar-gcc/#240 branch September 3, 2023 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ [Feature] Add some chain calls for Log facade
2 participants
0