Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
da81d79c
Commit
da81d79c
authored
6 years ago
by
Sydney Anne Erickson
Browse files
Options
Downloads
Patches
Plain Diff
Move fmt.Printf statements to use jww logging
parent
08044ae5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/root.go
+13
-13
13 additions, 13 deletions
cmd/root.go
with
13 additions
and
13 deletions
cmd/root.go
+
13
−
13
View file @
da81d79c
...
@@ -9,7 +9,6 @@ package cmd
...
@@ -9,7 +9,6 @@ package cmd
import
(
import
(
"encoding/base64"
"encoding/base64"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
...
@@ -72,7 +71,7 @@ func sessionInitialization() *id.User {
...
@@ -72,7 +71,7 @@ func sessionInitialization() *id.User {
if
sessionFile
==
""
{
if
sessionFile
==
""
{
client
,
err
=
api
.
NewClient
(
&
globals
.
RamStorage
{},
""
)
client
,
err
=
api
.
NewClient
(
&
globals
.
RamStorage
{},
""
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Could Not Initialize Ram Storage: %s
\n
"
,
globals
.
Log
.
ERROR
.
Printf
(
"Could Not Initialize Ram Storage: %s
\n
"
,
err
.
Error
())
err
.
Error
())
return
id
.
ZeroID
return
id
.
ZeroID
}
}
...
@@ -88,7 +87,8 @@ func sessionInitialization() *id.User {
...
@@ -88,7 +87,8 @@ func sessionInitialization() *id.User {
register
=
true
register
=
true
}
else
{
}
else
{
//Fail if any other error is received
//Fail if any other error is received
fmt
.
Printf
(
"Error with file path: %s
\n
"
,
err1
.
Error
())
globals
.
Log
.
ERROR
.
Printf
(
"Error with file path: %s
\n
"
,
err1
.
Error
())
return
id
.
ZeroID
}
}
}
}
...
@@ -96,7 +96,7 @@ func sessionInitialization() *id.User {
...
@@ -96,7 +96,7 @@ func sessionInitialization() *id.User {
client
,
err
=
api
.
NewClient
(
nil
,
sessionFile
)
client
,
err
=
api
.
NewClient
(
nil
,
sessionFile
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Could Not Initialize OS Storage: %s
\n
"
,
err
.
Error
())
globals
.
Log
.
ERROR
.
Printf
(
"Could Not Initialize OS Storage: %s
\n
"
,
err
.
Error
())
return
id
.
ZeroID
return
id
.
ZeroID
}
}
}
}
...
@@ -113,7 +113,7 @@ func sessionInitialization() *id.User {
...
@@ -113,7 +113,7 @@ func sessionInitialization() *id.User {
// If gwAddr was not passed via command line, check config file
// If gwAddr was not passed via command line, check config file
if
len
(
gateways
)
<
1
{
if
len
(
gateways
)
<
1
{
// No gateways in config file or passed via command line
// No gateways in config file or passed via command line
fmt
.
Printf
(
"Error: No gateway specified! Add to"
+
globals
.
Log
.
ERROR
.
Printf
(
"Error: No gateway specified! Add to"
+
" configuration file or pass via command line using -g!
\n
"
)
" configuration file or pass via command line using -g!
\n
"
)
return
id
.
ZeroID
return
id
.
ZeroID
}
else
{
}
else
{
...
@@ -150,7 +150,7 @@ func sessionInitialization() *id.User {
...
@@ -150,7 +150,7 @@ func sessionInitialization() *id.User {
uid
,
err
=
client
.
Register
(
userId
!=
0
,
regCode
,
""
,
mint
,
&
grp
)
uid
,
err
=
client
.
Register
(
userId
!=
0
,
regCode
,
""
,
mint
,
&
grp
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Could Not Register User: %s
\n
"
,
err
.
Error
())
globals
.
Log
.
ERROR
.
Printf
(
"Could Not Register User: %s
\n
"
,
err
.
Error
())
return
id
.
ZeroID
return
id
.
ZeroID
}
}
...
@@ -168,7 +168,7 @@ func sessionInitialization() *id.User {
...
@@ -168,7 +168,7 @@ func sessionInitialization() *id.User {
// This will also register the user email with UDB
// This will also register the user email with UDB
_
,
err
=
client
.
Login
(
uid
,
userEmail
)
_
,
err
=
client
.
Login
(
uid
,
userEmail
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Could Not Log In: %s
\n
"
,
err
)
globals
.
Log
.
ERROR
.
Printf
(
"Could Not Log In: %s
\n
"
,
err
)
return
id
.
ZeroID
return
id
.
ZeroID
}
}
...
@@ -228,7 +228,7 @@ func (l *FallbackListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
...
@@ -228,7 +228,7 @@ func (l *FallbackListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
senderNick
=
sender
.
Nick
senderNick
=
sender
.
Nick
}
}
atomic
.
AddInt64
(
&
l
.
messagesReceived
,
1
)
atomic
.
AddInt64
(
&
l
.
messagesReceived
,
1
)
fmt
.
Print
f
(
"Message of type %v from %q, %v received with fallback: %s
\n
"
,
globals
.
Log
.
INFO
.
Print
ln
(
"Message of type %v from %q, %v received with fallback: %s
\n
"
,
message
.
MessageType
,
*
message
.
Sender
,
senderNick
,
message
.
MessageType
,
*
message
.
Sender
,
senderNick
,
string
(
message
.
Body
))
string
(
message
.
Body
))
}
}
...
@@ -258,7 +258,7 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
...
@@ -258,7 +258,7 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
}
else
{
}
else
{
senderNick
=
sender
.
Nick
senderNick
=
sender
.
Nick
}
}
fmt
.
Print
f
(
"Message from %v, %v Received: %s
\n
"
,
large
.
NewIntFromBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
globals
.
Log
.
INFO
.
Print
ln
(
"Message from %v, %v Received: %s
\n
"
,
large
.
NewIntFromBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
senderNick
,
result
.
Message
)
senderNick
,
result
.
Message
)
atomic
.
AddInt64
(
&
l
.
messagesReceived
,
1
)
atomic
.
AddInt64
(
&
l
.
messagesReceived
,
1
)
...
@@ -282,7 +282,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
...
@@ -282,7 +282,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
senderNick
=
sender
.
Nick
senderNick
=
sender
.
Nick
}
}
fmt
.
Print
f
(
"Message from channel %v, %v: "
,
globals
.
Log
.
INFO
.
Print
ln
(
"Message from channel %v, %v: "
,
new
(
big
.
Int
)
.
SetBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
senderNick
)
new
(
big
.
Int
)
.
SetBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
senderNick
)
typedBody
,
_
:=
parse
.
Parse
(
result
.
Message
)
typedBody
,
_
:=
parse
.
Parse
(
result
.
Message
)
speakerId
:=
id
.
NewUserFromBytes
(
result
.
SpeakerID
)
speakerId
:=
id
.
NewUserFromBytes
(
result
.
SpeakerID
)
...
@@ -358,7 +358,7 @@ var rootCmd = &cobra.Command{
...
@@ -358,7 +358,7 @@ var rootCmd = &cobra.Command{
// Handle sending to any other destination
// Handle sending to any other destination
wireOut
:=
api
.
FormatTextMessage
(
message
)
wireOut
:=
api
.
FormatTextMessage
(
message
)
fmt
.
Print
f
(
"Sending Message to %d, %v: %s
\n
"
,
destinationUserId
,
globals
.
Log
.
INFO
.
Print
ln
(
"Sending Message to %d, %v: %s
\n
"
,
destinationUserId
,
recipientNick
,
message
)
recipientNick
,
message
)
// Send the message
// Send the message
...
@@ -388,7 +388,7 @@ var rootCmd = &cobra.Command{
...
@@ -388,7 +388,7 @@ var rootCmd = &cobra.Command{
if
ok
{
if
ok
{
contact
=
u
.
Nick
contact
=
u
.
Nick
}
}
fmt
.
Print
f
(
"Sending Message to %d, %v: %s
\n
"
,
destinationUserId
,
globals
.
Log
.
INFO
.
Print
ln
(
"Sending Message to %d, %v: %s
\n
"
,
destinationUserId
,
contact
,
message
)
contact
,
message
)
message
:=
&
parse
.
Message
{
message
:=
&
parse
.
Message
{
...
@@ -414,7 +414,7 @@ var rootCmd = &cobra.Command{
...
@@ -414,7 +414,7 @@ var rootCmd = &cobra.Command{
err
:=
client
.
Logout
()
err
:=
client
.
Logout
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Could not logout: %s
\n
"
,
err
.
Error
())
globals
.
Log
.
ERROR
.
Printf
(
"Could not logout: %s
\n
"
,
err
.
Error
())
return
return
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment