Documentation
¶
Overview ¶
Package cage copies all output to stdout, stderr and log output in a logfile.
Usage: cage.Name = cage.DefaultLogfileName cage.Enable() defer cage.Disable() do stuff... for capturing output in a string consider "import capturer "github.com/kami-zh/go-capturer"
TODO: debug code:
Problem: cage.Enable() re-direkted os.Stderr und dupliziert so Ausgaben an os.Sterr in trice.log hCmd.Output() usw. geben os.Stderr zurück. Das ist auch wirklich die re-directed Adresse. Der Paketest von cage funktioniert, auch TestScHelp() geht fehlerfrei durch. Wenn aber über die Kommandozeile "trice h" erfolgt, landen Ausgaben an os.Stderr NICHT in trice.log obwohl os.Stderr re-directed ist. log.SetFlags(0) fmt.Println("0: os.Stderr addr:", os.Stderr) // ok not in trice.log cage.Enable() defer cage.Disable() fmt.Println("1: os.Stderr addr:", os.Stderr) // ok in trice.log (os.Stdout) fmt.Println("2: hCmd.Output() addr:", hCmd.Output()) // ok in trice.log (os.Stdout) fmt.Fprintln(os.Stderr, "3: OS.STDERR") // NOT in trice.log fmt.Fprintln(hCmd.Output(), "4: hCmd.Output()") // NOT in trice.log log.Println("5: TryIt") // ok in trice.log (log out) fmt.Println("6: TryIt2") // ok in trice.log (os.Stdout) fmt.Fprintln(os.Stdout, "7: OS.STDOUT") // ok in trice.log (os.Stdout)
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultLogfileName is the pattern for default logfile name. The timestamp is replaced with the actual time. DefaultLogfileName = "2006-01-02_1504-05_cage.log" // Name is the filename of the logfile. "off" inhibits logfile writing. Name = "off" )
Functions ¶
func Disable ¶
func Disable()
Disable ends take notes mode, means parallel writing into a file. It takes no effect when pContainer is nil, what is the case when Enable was started with "off" or "none" as 'Name'.
Types ¶
Click to show internal directories.
Click to hide internal directories.