1 /* various important shared defaults. */
13 DefaultMasterPort = 2258
14 DefaultHTTPPort = 2259
17 var logWriter *syslog.Writer = nil
19 func SetLogName(name string) {
25 logWriter, err = syslog.New(syslog.LOG_DEBUG, name)
26 MightFail(err, "Couldn't reopen syslog")
30 func Debug(format string, args ...interface{}) {
32 logWriter.Debug(fmt.Sprintf(format, args...))
36 func Info(format string, args ...interface{}) {
38 logWriter.Info(fmt.Sprintf(format, args...))
42 func Warn(format string, args ...interface{}) {
44 logWriter.Warning(fmt.Sprintf(format, args...))
48 func Fail(mesg string, args ...interface {}) {
50 logWriter.Err(fmt.Sprintf(mesg, args...))
52 fmt.Fprintf(os.Stderr, "ERR: "+mesg+"\n", args...);
56 func MightFail(err os.Error, mesg string, args ...interface {}) {
58 imesg := fmt.Sprintf(mesg, args...)
59 Fail("%s: %s", imesg, err.String())
63 // Throws a generic assertion error, stacktraces, dies.
64 // only really to be used where the runtime-time configuration
65 // fucks up internally, not for user induced errors.
66 func Assert(mesg string, args ...interface{}) {
67 fmt.Fprintf(os.Stderr, mesg, args...)
72 func ProbeHostname() (fqdn string) {
73 var shortHostname string
75 shortHostname, err := os.Hostname()
76 addr, err := net.LookupHost(shortHostname)
77 MightFail(err, "Failed to get address for hostname")
78 hostnames, err := net.LookupAddr(addr[0])
79 MightFail(err, "Failed to get full hostname for address")