Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-shell
Commits
9087e960
Commit
9087e960
authored
Mar 23, 2018
by
Jacob Vosmaer (GitLab)
Committed by
Douwe Maan
Mar 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flush log file after every write
parent
e19b08ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
1 deletion
+32
-1
CHANGELOG
CHANGELOG
+3
-0
VERSION
VERSION
+1
-1
bin/test-logger
bin/test-logger
+10
-0
lib/gitlab_logger.rb
lib/gitlab_logger.rb
+6
-0
spec/gitlab_logger_spec.rb
spec/gitlab_logger_spec.rb
+12
-0
No files found.
CHANGELOG
View file @
9087e960
v7.1.1
- Flush log file after every write (!199)
v7.1.0
- Migrate `git-upload-archive` to gitaly
...
...
VERSION
View file @
9087e960
7.1.
0
7.1.
1
bin/test-logger
0 → 100755
View file @
9087e960
#!/usr/bin/env ruby
# The purpose of this executable is to test that gitlab-shell logging
# works correctly in combination with Kernel.exec.
require_relative
'../lib/gitlab_init'
require_relative
'../lib/gitlab_logger'
$logger
.
info
(
ARGV
.
first
)
Kernel
.
exec
(
'true'
)
lib/gitlab_logger.rb
View file @
9087e960
...
...
@@ -25,7 +25,13 @@ class GitlabLogger
def
initialize
(
level
,
path
,
log_format
)
@level
=
level
@log_file
=
File
.
open
(
path
,
'ab'
)
# By default Ruby will buffer writes. This is a problem when we exec
# into a new command before Ruby flushed its buffers. Setting 'sync' to
# true disables Ruby's buffering.
@log_file
.
sync
=
true
@log_format
=
log_format
end
...
...
spec/gitlab_logger_spec.rb
View file @
9087e960
require_relative
'spec_helper'
require_relative
'../lib/gitlab_logger'
require
'securerandom'
describe
:convert_log_level
do
subject
{
convert_log_level
:extreme
}
...
...
@@ -112,4 +113,15 @@ describe GitlabLogger do
expect
(
JSON
.
parse
(
first_line
)).
to
include
(
'msg'
=>
'"hello\x80world"'
)
end
end
describe
'log flushing'
do
it
'logs get written even when calling Kernel.exec'
do
msg
=
SecureRandom
.
hex
(
12
)
test_logger_status
=
system
(
'bin/test-logger'
,
msg
)
expect
(
test_logger_status
).
to
eq
(
true
)
grep_status
=
system
(
'grep'
,
'-q'
,
'-e'
,
msg
,
GitlabConfig
.
new
.
log_file
)
expect
(
grep_status
).
to
eq
(
true
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment