ExampleServer_ignoreLogsSometimes shows you how to ignore all of the log messages written by a tsnet instance, but allows you to opt-into them if a command-line flag is set.
()
| 95 | // written by a tsnet instance, but allows you to opt-into them if a command-line |
| 96 | // flag is set. |
| 97 | func ExampleServer_ignoreLogsSometimes() { |
| 98 | tsnetVerbose := flag.Bool("tsnet-verbose", false, "if set, verbosely log tsnet information") |
| 99 | hostname := flag.String("tsnet-hostname", "hikari", "hostname to use on the tailnet") |
| 100 | |
| 101 | srv := &tsnet.Server{ |
| 102 | Hostname: *hostname, |
| 103 | } |
| 104 | |
| 105 | if *tsnetVerbose { |
| 106 | srv.Logf = log.New(os.Stderr, fmt.Sprintf("[tsnet:%s] ", *hostname), log.LstdFlags).Printf |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // ExampleServer_HTTPClient shows you how to make HTTP requests over your tailnet. |
| 111 | // |