71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
46 lines
909 B
Go
46 lines
909 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// The logtail program logs stdin.
|
|
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"flag"
|
|
"io"
|
|
"log"
|
|
"os"
|
|
|
|
"tailscale.com/logtail"
|
|
)
|
|
|
|
func main() {
|
|
collection := flag.String("c", "", "logtail collection name")
|
|
privateID := flag.String("k", "", "machine private identifier, 32-bytes in hex")
|
|
flag.Parse()
|
|
if len(flag.Args()) != 0 {
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
log.SetFlags(0)
|
|
|
|
var id logtail.PrivateID
|
|
if err := id.UnmarshalText([]byte(*privateID)); err != nil {
|
|
log.Fatalf("logtail: bad -privateid: %v", err)
|
|
}
|
|
|
|
logger := logtail.NewLogger(logtail.Config{
|
|
Collection: *collection,
|
|
PrivateID: id,
|
|
}, log.Printf)
|
|
log.SetOutput(io.MultiWriter(logger, os.Stdout))
|
|
defer logger.Flush()
|
|
defer log.Printf("logtail exited")
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
for scanner.Scan() {
|
|
log.Println(scanner.Text())
|
|
}
|
|
}
|