Skip to content

Conversation

arp242
Copy link
Member

@arp242 arp242 commented Apr 25, 2024

This can be used to print events to stderr:

[~cg/fsnotify](dbg)% FSNOTIFY_DEBUG=1 fsnotify watch /tmp/ >/dev/null
FSNOTIFY_DEBUG: 11:34:23.633087586   256:IN_CREATE            → "/tmp/a"
FSNOTIFY_DEBUG: 11:34:23.633202319     4:IN_ATTRIB            → "/tmp/a"
FSNOTIFY_DEBUG: 11:34:26.782035307   256:IN_CREATE            → "/tmp/b"
FSNOTIFY_DEBUG: 11:34:26.782137248     4:IN_ATTRIB            → "/tmp/b"
FSNOTIFY_DEBUG: 11:34:28.989728764   512:IN_DELETE            → "/tmp/a"
FSNOTIFY_DEBUG: 11:34:30.356208544     2:IN_MODIFY            → "/tmp/b"
FSNOTIFY_DEBUG: 11:34:30.356272832     4:IN_ATTRIB            → "/tmp/b"
FSNOTIFY_DEBUG: 11:34:32.957233528   512:IN_DELETE            → "/tmp/b"

The internal.Debug() functions already existed; I sometimes added this manually during development. This makes it more broadly useful. Can be useful to debug some issues.

@arp242 arp242 force-pushed the dbg branch 4 times, most recently from 5e00063 to 19a7900 Compare April 25, 2024 12:20
This can be used to print events to stderr:

	[~cg/fsnotify](dbg)% FSNOTIFY_DEBUG=1 fsnotify watch /tmp/ >/dev/null
	FSNOTIFY_DEBUG: 11:34:23.633087586   256:IN_CREATE            → "/tmp/a"
	FSNOTIFY_DEBUG: 11:34:23.633202319     4:IN_ATTRIB            → "/tmp/a"
	FSNOTIFY_DEBUG: 11:34:26.782035307   256:IN_CREATE            → "/tmp/b"
	FSNOTIFY_DEBUG: 11:34:26.782137248     4:IN_ATTRIB            → "/tmp/b"
	FSNOTIFY_DEBUG: 11:34:28.989728764   512:IN_DELETE            → "/tmp/a"
	FSNOTIFY_DEBUG: 11:34:30.356208544     2:IN_MODIFY            → "/tmp/b"
	FSNOTIFY_DEBUG: 11:34:30.356272832     4:IN_ATTRIB            → "/tmp/b"
	FSNOTIFY_DEBUG: 11:34:32.957233528   512:IN_DELETE            → "/tmp/b"

The internal.Debug() functions already existed; I sometimes added this
manually during development. This makes it more broadly useful. Can be
useful to debug some issues.
@arp242 arp242 merged commit 77d5fee into main Apr 25, 2024
@arp242 arp242 deleted the dbg branch April 25, 2024 12:39
@arp242 arp242 mentioned this pull request Apr 25, 2024
@SuperQ
Copy link

SuperQ commented Nov 2, 2024

Would you mind if this were replaced with a logging interface, rather than directly printing to stderr?

This would be nicer for applications that are using their own logging libraries.

This can be done with a simple stdlog compatible interface, or a Go log/slog compatible interface.

@arp242
Copy link
Member Author

arp242 commented Nov 3, 2024

This is just to facilitate printing something so people reporting "I have a problem with some random program" can provide more information, similar to GODEBUG, the race detector, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants