Skip to content
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

command: introduce DebugPrintf #830

Merged
merged 1 commit into from
Jan 7, 2017
Merged

command: introduce DebugPrintf #830

merged 1 commit into from
Jan 7, 2017

Conversation

odeke-em
Copy link
Owner

@odeke-em odeke-em commented Jan 7, 2017

Introduce DebugPrintf which can be used to give
contextual and debug information when things go wrong
and we need to observe them, when verbose or DEBUG=true
is set in the environment.

So far added debugging prints when parsing the .driverc file.
It prints out the:
[::<LINE_NUMBER>]

Prefix a drive invocation with DEBUG=true

$ DEBUG=true drive list share-testing/
[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/cmd/drive/main.go:main.discoverContext:1857]
contextPath: /Users/emmanuelodeke/[email protected]/share-testing
[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/cmd/drive/main.go:main.discoverContext:1867]
driveRoot: "/Users/emmanuelodeke/[email protected]" relToRoot: ""

[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/src/rc.go:github.com/odeke-em/drive/src.ResourceMappings:92]
RCPath: /Users/emmanuelodeke/[email protected]/share-testing/.driverc
[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/src/rc.go:github.com/odeke-em/drive/src.ResourceMappings:108]
parsedContent from
"/Users/emmanuelodeke/[email protected]/share-testing/.driverc"
{
  "global": {
    "depth": -1
  }
}
[Commands.List] #0 "/share-testing"
-- owner       175.00B	  0Bwu8laYc9RTPa28zVk9Td2hTVWc	  2016-06-30
15:32:25 +0000 UTC  /share-testing/SciqPCKrhi.go
-- owner       309.00B	  0Bwu8laYc9RTPTXRYblNqQXBSQzQ	  2016-02-03
08:12:15 +0000 UTC  /share-testing/outf.go
-s owner       39.70KB	  0Bwu8laYc9RTPOVNSeElpdFBpS2M	  2012-02-02
12:00:00 +0000 UTC  /share-testing/ComedyPunchlineDrumSound.mp3

It will alleviate #829
since the reporter could then investigate and see the .gd path and
.driverc paths that were being read from.

Introduce DebugPrintf which can be used to give
contextual and debug information when things go wrong
and we need to observe them, when verbose or `DEBUG=true`
is set in the environment.

So far added debugging prints when parsing the .driverc file.
It prints out the:
[<FILE>:<FUNCTION>:<LINE_NUMBER>]

Prefix a drive invocation with `DEBUG=true`
```shell
$ DEBUG=true drive list share-testing/
[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/cmd/drive/main.go:main.discoverContext:1857]
contextPath: /Users/emmanuelodeke/[email protected]/share-testing
[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/cmd/drive/main.go:main.discoverContext:1867]
driveRoot: "/Users/emmanuelodeke/[email protected]" relToRoot: ""

[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/src/rc.go:github.com/odeke-em/drive/src.ResourceMappings:92]
RCPath: /Users/emmanuelodeke/[email protected]/share-testing/.driverc
[/Users/emmanuelodeke/go/src/github.com/odeke-em/drive/src/rc.go:github.com/odeke-em/drive/src.ResourceMappings:108]
parsedContent from
"/Users/emmanuelodeke/[email protected]/share-testing/.driverc"
{
  "global": {
    "depth": -1
  }
}
[Commands.List] #0 "/share-testing"
-- owner       175.00B	  0Bwu8laYc9RTPa28zVk9Td2hTVWc	  2016-06-30
15:32:25 +0000 UTC  /share-testing/SciqPCKrhi.go
-- owner       309.00B	  0Bwu8laYc9RTPTXRYblNqQXBSQzQ	  2016-02-03
08:12:15 +0000 UTC  /share-testing/outf.go
-s owner       39.70KB	  0Bwu8laYc9RTPOVNSeElpdFBpS2M	  2012-02-02
12:00:00 +0000 UTC  /share-testing/ComedyPunchlineDrumSound.mp3
```

It will alleviate #829
since the reporter could then investigate and see the .gd path and
.driverc paths that were being read from.
@odeke-em odeke-em merged commit 467def2 into master Jan 7, 2017
@odeke-em odeke-em added this to the v0.3.9 milestone Jan 7, 2017
odeke-em added a commit that referenced this pull request Jan 7, 2017
Updates #830.

Replace `DEBUG` with `DRIVE_DEBUG` to avoid clashes with other
programs that might need the `DEBUG` flag. `DRIVE_DEBUG` makes
it clear that this debug is only for drive.
@odeke-em odeke-em deleted the introduce-debugf branch January 7, 2017 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant