Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@
package format

import (
"bytes"
"encoding/json"
"fmt"
"github.com/bobziuchkovski/cue"
"os"
"os/exec"
"reflect"
"sort"
"strconv"
"strings"
"time"
"unicode"
"unicode"
)

// Color codes for use with Colorize.
Expand Down Expand Up @@ -278,11 +280,12 @@ func Hostname(buffer Buffer, event *cue.Event) {
// FQDN writes the host's fully-qualified domain name (FQDN) to the buffer.
// If the FQDN cannot be determined, "unknown" is written instead.
func FQDN(buffer Buffer, event *cue.Event) {
name, err := os.Hostname()
if err != nil {
name = "unknown"
out, err := exec.Command("/bin/hostname", "-f").Output()
if err == nil {
buffer.Append(bytes.TrimSpace(out))
} else {
buffer.AppendString("unknown")
}
buffer.AppendString(name)
}

// Level writes event.Level.String() to the buffer. Hence, it writes "INFO"
Expand Down