func ExampleLogger_SwitchFile() { // Initialize logger with file. var err error var f *os.File if f, err = os.Open("sys.log"); err != nil { return } ol.Switch(f) // When need to reap log file, // user must close current log file. ol.Close() // User can move the sys.log away. // Then reopen the log file and notify logger to use it. if f, err = os.Open("sys.log"); err != nil { return } // All logs between close and switch are dropped. ol.Switch(f) // Always close it. defer ol.Close() }
func ExampleLogger_ToFile() { // Open logger file and change the tank for logger. var err error var f *os.File if f, err = os.Open("sys.log"); err != nil { return } ol.Switch(f) // Use logger, which will write to file. ol.T(nil, "The log text.") // Close logger file when your application quit. defer ol.Close() }