Example #1
0
func Example_combinedOutputs() {
	conf := xlog.Config{
		Output: xlog.NewOutputChannel(xlog.MultiOutput{
			// Output interesting messages to console
			0: xlog.FilterOutput{
				Cond: func(fields map[string]interface{}) bool {
					val, found := fields["type"]
					return found && val == "interesting"
				},
				Output: xlog.NewConsoleOutput(),
			},
			// Also setup by-level loggers
			1: xlog.LevelOutput{
				// Send debug messages to console if they match type
				Debug: xlog.FilterOutput{
					Cond: func(fields map[string]interface{}) bool {
						val, found := fields["type"]
						return found && val == "interesting"
					},
					Output: xlog.NewConsoleOutput(),
				},
			},
			// Also send everything over syslog
			2: xlog.NewSyslogOutput("", "", ""),
		}),
	}

	lh := xlog.NewHandler(conf)
	_ = lh
}
Example #2
0
func ExampleMultiOutput() {
	conf := xlog.Config{
		Output: xlog.NewOutputChannel(xlog.MultiOutput{
			// Output everything to console
			0: xlog.NewConsoleOutput(),
			// and also to local syslog
			1: xlog.NewSyslogOutput("", "", ""),
		}),
	}
	lh := xlog.NewHandler(conf)
	_ = lh
}
Example #3
0
func ExampleLevelOutput() {
	conf := xlog.Config{
		Output: xlog.NewOutputChannel(xlog.LevelOutput{
			// Send debug message to console
			Debug: xlog.NewConsoleOutput(),
			// and error messages to syslog
			Error: xlog.NewSyslogOutput("", "", ""),
			// other levels are discarded
		}),
	}

	lh := xlog.NewHandler(conf)
	_ = lh
}