Exemplo n.º 1
0
func (m *MsgLog) PrtMsgs(state interfaces.IState) {
	m.sem.Lock()
	defer m.sem.Unlock()

	if len(m.MsgList) == 0 {
		return
	}

	fmt.Println(state.String())
	fmt.Println("\n-----------------------------------------------------")

	for _, e := range m.MsgList {
		if e.valid {

			dirstr := "->"
			if !e.out {
				dirstr = "<-"
			}

			fmt.Print(fmt.Sprintf("**** %8s %2s %8s %10s %5v     **** %s\n", e.name, dirstr, e.peer, e.where, e.valid, e.msg.String()))

		}
	}
	now := state.GetTimestamp()
	m.last = now
	m.msgCnt += len(m.MsgList) // Keep my counts
	m.msgCntp += len(m.MsgList)
	m.MsgList = m.MsgList[0:0] // Once printed, clear the list

	fmt.Println(fmt.Sprintf("*** %42s **** ", fmt.Sprintf("Length: %d    Msgs/sec: T %d P %d", len(m.MsgList), m.msgPerSec, m.msgPerSecp)))
	fmt.Println("\n-----------------------------------------------------")
}
Exemplo n.º 2
0
func PrintBusy(state interfaces.IState, i int) {

	s := state.(*s.State)

	if len(s.ShutdownChan) == 0 {
		if state.GetOut() {
			state.Print(fmt.Sprintf("\r%19s: %s %s",
				"Timer",
				state.String(),
				(string)((([]byte)("-\\|/-\\|/-="))[i])))
		}
	}

}