-
-
Notifications
You must be signed in to change notification settings - Fork 539
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 your account
feat:(logging) Added Log Format provision #8890
base: main
Are you sure you want to change the base?
Conversation
So, all you've done is make the configuration valid in the configuration YAML file. Now, you have to plumb it through to change the actual logging behavior. And finally, you should write some tests to make sure it actually logs in JSON if you have the setting enabled. |
@timsehn Can you take a look whether I am heading in the right direction? |
You are heading in the right direction. It looks like you have most of the places to actually get the value to the server. Now the server needs to read it when it wants to emit a log line and emit the right format. @zachmu suggested that logic is here: https://github.com/dolthub/dolt/blob/main/go/cmd/dolt/commands/sqlserver/server.go#L117 Looking at logrus (https://github.com/sirupsen/logrus), it seems they have JSON formatting capability. IN their README, they suggest
|
@timsehn I have configured the logger for log_format but i am not sure how can I test the same with a logger. Update:- |
That looks like it is working. I'm not sure the best way to write tests for this. @zachmu should answer. |
Hi @damanV5, This looks really good. You should add a test for the new option in the bats file here, similar to this one: https://github.com/dolthub/dolt/blob/main/integration-tests/bats/sql-server.bats#L123 You can check the output format is correct by redirecting the log to a file, like this test does: https://github.com/dolthub/dolt/blob/main/integration-tests/bats/sql-server.bats#L1531 |
Can this very first line too be in json? |
Need to figure something out here, The following test is working fine for insensitivity when checked from command line but from config.yaml it is behaving sensitive. So, that I need to figure out. Test:-
|
@zachmu Update: I managed to add a test case for |
Running tests now. |
@@ -145,6 +145,32 @@ EOF | |||
dolt sql -q "show databases;" | |||
stop_sql_server | |||
} | |||
@test "sql-server: logformats are case insensitive" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a test here to assert that the log outputted in json format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timsehn Added.
Also, you must fix the Go tests this broke. |
It's odd that the Go tests passed with No race but failed with race on. |
@timsehn I have fixed the go tests for sqlserver. Do i also need to update |
Added
log_format
feature for logger.