var journalSocket … var unixConnPtr … var onceConn … // Enabled checks whether the local systemd journal is available for logging. func Enabled() bool { … } // StderrIsJournalStream returns whether the process stderr is connected // to the Journal's stream transport. // // This can be used for automatic protocol upgrading described in [Journal Native Protocol]. // // Returns true if JOURNAL_STREAM environment variable is present, // and stderr's device and inode numbers match it. // // Error is returned if unexpected error occurs: e.g. if JOURNAL_STREAM environment variable // is present, but malformed, fstat syscall fails, etc. // // [Journal Native Protocol]: https://systemd.io/JOURNAL_NATIVE_PROTOCOL/#automatic-protocol-upgrading func StderrIsJournalStream() (bool, error) { … } // StdoutIsJournalStream returns whether the process stdout is connected // to the Journal's stream transport. // // Returns true if JOURNAL_STREAM environment variable is present, // and stdout's device and inode numbers match it. // // Error is returned if unexpected error occurs: e.g. if JOURNAL_STREAM environment variable // is present, but malformed, fstat syscall fails, etc. // // Most users should probably use [StderrIsJournalStream]. func StdoutIsJournalStream() (bool, error) { … } func fdIsJournalStream(fd int) (bool, error) { … } // Send a message to the local systemd journal. vars is a map of journald // fields to values. Fields must be composed of uppercase letters, numbers, // and underscores, but must not start with an underscore. Within these // restrictions, any arbitrary field name may be used. Some names have special // significance: see the journalctl documentation // (http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html) // for more details. vars may be nil. func Send(message string, priority Priority, vars map[string]string) error { … } // getOrInitConn attempts to get the global `unixConnPtr` socket, initializing if necessary func getOrInitConn() *net.UnixConn { … } func appendVariable(w io.Writer, name, value string) { … } // validVarName validates a variable name to make sure journald will accept it. // The variable name must be in uppercase and consist only of characters, // numbers and underscores, and may not begin with an underscore: // https://www.freedesktop.org/software/systemd/man/sd_journal_print.html func validVarName(name string) error { … } // isSocketSpaceError checks whether the error is signaling // an "overlarge message" condition. func isSocketSpaceError(err error) bool { … } // tempFd creates a temporary, unlinked file under `/dev/shm`. func tempFd() (*os.File, error) { … } // initConn initializes the global `unixConnPtr` socket. // It is automatically called when needed. func initConn() { … }