-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add logging to unified file #345
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ochaplashkin
force-pushed
the
unified-logging
branch
3 times, most recently
from
December 21, 2023 15:27
ebdf6bf
to
d4ef87b
Compare
Merged
ochaplashkin
force-pushed
the
unified-logging
branch
2 times, most recently
from
January 11, 2024 14:56
169a59a
to
c25cfef
Compare
ochaplashkin
commented
Jan 11, 2024
ochaplashkin
force-pushed
the
unified-logging
branch
9 times, most recently
from
January 24, 2024 15:40
0fd10ec
to
bde250e
Compare
ochaplashkin
force-pushed
the
unified-logging
branch
10 times, most recently
from
January 25, 2024 16:16
ff25d72
to
fad8ed6
Compare
ochaplashkin
force-pushed
the
unified-logging
branch
from
January 25, 2024 16:18
fad8ed6
to
890f7b2
Compare
I tested this patch and saw that one test needed to be changed:
|
ochaplashkin
force-pushed
the
unified-logging
branch
3 times, most recently
from
January 26, 2024 13:54
db722ed
to
db1ec46
Compare
We present a new functionality for logging. > How it worked before Having written a simple test with two servers (bob and frank) we would like to see the output of each of them and also what is going on in the test itself. For example: g.test_with_bob_and_frank = function() g.bob:exec(function() require('log').info('Hi, Frank!') end) g.frank:exec(function() require('log').info('Hi, Bob!') end) require('log').info('Hi, Bob and Frank!') end In order to see their greetings, we had to look over each server log file: $ cat /tmp/t/${BOB_VARDIR}/bob.log ... 2023-12-19 18:34:26.305 [84739] main/109/main I> Hi, Frank! $ cat /tmp/t/${FRANK_VARDIR}/frank.log ... 2023-12-19 18:34:26.306 [84752] main/109/main I> Hi, Bob! And there was no way to see the "Hi, Bob and Frank!" log message at all. > How it works now Now, if we provide the `-l, --log` parameter with the file path, we will see the following contents in the specified log file: $ ./bin/luatest -c -v -l run.log <test> && cat run.log ... bob | 2023-12-19 18:39:40.858 [85021] main/109/main I> Hi, Frank! frank | 2023-12-19 18:39:40.859 [85034] main/109/main I> Hi, Bob! luatest | 2023-12-19 18:39:40.860 [85034] main/109/main I> Hi, Bob and Frank! > What's under the hood The solution is based on the existing OutputBeautifier module logic: it can already read data from standard output streams (stdout/stderr) and print it to luatest stdout. When we run luatest (this is Tarantool process), we read stderr stream and hijack it. All logs of this process will be written to stderr and intercepted by the OutputBeautifier fiber. The fiber processes them and writes to our specified file for all logs and then to the luatest stdout stream. To save the log file for each server separately (this can be useful for research) we use the standard `tee` command. In the case of the server, we configure logging as follows: ' | tee ${TARANTOOL_WORKDIR}/${TARANTOOL_ALIAS}.log' While the server is running, all logs will be redirected to the `tee` command. So it will be written to the server log file and stdout stream. Then all data from stdout will be intercepted by the OutputBeautifier fiber that will write it to the specified log file. > What's new in administration New options: `-l, --log PATH` - set the path to the unified log file. `--runner-log-prefix NAME` - set the log prefix for luatest runner, 'luatest' by default. Improved options: `-v` - increase output verbosity (as it was before) and set `INFO` log level for luatest runner. `-vv` - increase log verbosity to `VERBOSE` level for luatest runnner. `-vvv` - increase log verbosity to `DEBUG` level for luatest runnner. Closes tarantool#324
ochaplashkin
force-pushed
the
unified-logging
branch
from
January 26, 2024 14:00
db1ec46
to
e528607
Compare
ylobankov
approved these changes
Jan 29, 2024
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.
LGTM
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
❤️ We present a new functionality for logging ❤️
How it worked before
Having written a simple test with two servers (bob and frank) we would like to see the output of each of them and also what is going on in the test itself. For example:
In order to see their greetings, we had to look over each server log file:
And there was no way to see the "Hi, Bob and Frank!" log message.
How it works now
Now, if we provide the
-l, --log
parameter with the file path, we will see the following contents in the specified log file:What's under the hood
Data flow diagram
The solution is based on the existing OutputBeautifier module logic: it can already read data from standard output streams (stdout/stderr) and print it to luatest stdout.
When we run luatest (this is Tarantool process), we read stderr stream and hijack it. All logs of this process will be written to stderr and intercepted by the OutputBeautifier fiber. The fiber processes them and writes to our specified file for all logs and then to the luatest stdout stream.
To save the log file for each server separately (this can be useful for research) we use the standard
tee
command.In the case of the server, we configure logging as follows:
While the server is running, all logs will be redirected to the
tee
command. So it will be written to the server log file and stdout stream. Then all data from stdout will be intercepted by the OutputBeautifier fiber that will write it to the specified log file.What's new in administration
New options:
-l, --log PATH
- set the path to the unified log file.--runner-log-prefix NAME
- set the log prefix for luatest runner,'luatest' by default.
Improved options:
-v
- increase output verbosity (as it was before) and setINFO
loglevel for luatest runner.
-vv
- increase log verbosity toVERBOSE
level for luatest runnner.-vvv
- increase log verbosity toDEBUG
level for luatest runnner.A few words about backward compatibility (< 2.5.1)
Logging cannot be initialized without configuring the
box
engine on a version less than 2.5.1. Otherwise, this causes theattempt to call field 'cfg' (a nil value)
error, so there are the following limitations:luatest.log
file (but logs are still available in stdout and in therun.log
file);Closes #324