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
33d583bf
Commit
33d583bf
authored
May 03, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change signature of logger.Fatal
parent
25a32cfa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
go/cmd/gitaly-receive-pack/main.go
go/cmd/gitaly-receive-pack/main.go
+3
-3
go/cmd/gitaly-upload-pack/main.go
go/cmd/gitaly-upload-pack/main.go
+3
-3
go/internal/logger/logger.go
go/internal/logger/logger.go
+11
-10
No files found.
go/cmd/gitaly-receive-pack/main.go
View file @
33d583bf
...
...
@@ -16,15 +16,15 @@ func init() {
func
main
()
{
if
err
:=
handler
.
Prepare
();
err
!=
nil
{
logger
.
Fatal
(
err
)
logger
.
Fatal
(
"preparation failed"
,
err
)
}
var
request
pb
.
SSHReceivePackRequest
if
err
:=
json
.
Unmarshal
([]
byte
(
os
.
Args
[
2
]),
&
request
);
err
!=
nil
{
logger
.
Fatal
(
err
)
logger
.
Fatal
(
"unmarshaling request json failed"
,
err
)
}
if
err
:=
handler
.
ReceivePack
(
os
.
Args
[
1
],
&
request
);
err
!=
nil
{
logger
.
Fatal
(
err
)
logger
.
Fatal
(
"receive-pack failed"
,
err
)
}
}
go/cmd/gitaly-upload-pack/main.go
View file @
33d583bf
...
...
@@ -16,15 +16,15 @@ func init() {
func
main
()
{
if
err
:=
handler
.
Prepare
();
err
!=
nil
{
logger
.
Fatal
(
err
)
logger
.
Fatal
(
"preparation failed"
,
err
)
}
var
request
pb
.
SSHUploadPackRequest
if
err
:=
json
.
Unmarshal
([]
byte
(
os
.
Args
[
2
]),
&
request
);
err
!=
nil
{
logger
.
Fatal
(
err
)
logger
.
Fatal
(
"unmarshaling request json failed"
,
err
)
}
if
err
:=
handler
.
UploadPack
(
os
.
Args
[
1
],
&
request
);
err
!=
nil
{
logger
.
Fatal
(
err
)
logger
.
Fatal
(
"upload-pack failed"
,
err
)
}
}
go/internal/logger/logger.go
View file @
33d583bf
...
...
@@ -31,24 +31,26 @@ func Configure(cfg *config.Config) error {
return
err
}
func
logPrint
(
msg
...
interface
{}
)
{
func
logPrint
(
msg
string
,
err
error
)
{
mutex
.
Lock
()
defer
mutex
.
Unlock
()
if
logWriter
==
nil
{
bootstrapLogPrint
(
msg
...
)
bootstrapLogPrint
(
msg
,
err
)
return
}
// Emulate the existing log format of gitlab-shell
t
:=
time
.
Now
()
.
Format
(
"2006-01-02T15:04:05.999999"
)
prefix
:=
fmt
.
Sprintf
(
"E, [%s #%d] ERROR -- : %s:
"
,
t
,
pid
,
ProgName
)
fmt
.
Fprint
ln
(
logWriter
,
append
([]
interface
{}{
prefix
},
msg
...
)
...
)
prefix
:=
fmt
.
Sprintf
(
"E, [%s #%d] ERROR -- : %s:"
,
t
,
pid
,
ProgName
)
fmt
.
Fprint
f
(
logWriter
,
"%s %s: %v
\n
"
,
prefix
,
msg
,
err
)
}
func
Fatal
(
msg
...
interface
{})
{
logPrint
(
msg
...
)
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: fatal error
\n
"
,
ProgName
)
func
Fatal
(
msg
string
,
err
error
)
{
logPrint
(
msg
,
err
)
// We don't show the error to the end user because it can leak
// information that is private to the GitLab server.
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: fatal: %s
\n
"
,
ProgName
,
msg
)
os
.
Exit
(
1
)
}
...
...
@@ -57,7 +59,7 @@ func Fatal(msg ...interface{}) {
// function attemps to log to syslog.
//
// We assume the logging mutex is already locked.
func
bootstrapLogPrint
(
msg
...
interface
{}
)
{
func
bootstrapLogPrint
(
msg
string
,
err
error
)
{
if
bootstrapLogger
==
nil
{
var
err
error
bootstrapLogger
,
err
=
syslog
.
NewLogger
(
syslog
.
LOG_ERR
|
syslog
.
LOG_USER
,
0
)
...
...
@@ -67,6 +69,5 @@ func bootstrapLogPrint(msg ...interface{}) {
}
}
args
:=
append
([]
interface
{}{
ProgName
+
":"
},
msg
...
)
bootstrapLogger
.
Print
(
args
)
bootstrapLogger
.
Print
(
ProgName
+
":"
,
msg
+
":"
,
err
)
}
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