func Limit(Max,Second,TimeOut int) (*Limitl) {
- returnVal := Limitl{}
- if Max < 1 || Second < 1 || TimeOut < Second{return &returnVal}
+ // Logf().NoShow(false)
- returnVal = Limitl{
+ if Max < 1 {
+ Logf().E("Limit:Max < 1 is true.Set to 1")
+ Max = 1
+ }
+
+ returnVal := Limitl{
Max:Max,
+ Channl:make(chan bool,Max),
+ }
+
+ if Second < 1 || TimeOut < Second{
+ Logf().E("Limit:Second < 1 || TimeOut < Second is true.Set Stop to true")
+ returnVal.Stop = true
+ return &returnVal
+ }
+
+ returnVal = Limitl{
Second:Second,
TimeOut:TimeOut,
- Channl:make(chan bool,Max),
}
go func(returnVal *Limitl){
type logl struct {
fileName string
+ noShow bool
channelN chan int
channel chan interface{}
wantLog chan bool
for len(l.channelN) != 0 {
i := <- l.channelN
+ if l.noShow {continue}
switch i {
case -1:
l.Close()
}()
}
+func (l *logl) NoShow(NoShow bool){
+ l.noShow = NoShow
+}
+
func (l *logl) Close(){
l.fileName = ""
}
}
func (l *logl) T(i ...interface{}){
+ if l.noShow {return}
if l.fileName == "" {log.Println("TRACE:", i);return}
l.channelN <- 0
l.channel <- i
if len(l.wantLog) ==0 {l.wantLog <- true;l.wantLog <- true}
}
func (l *logl) I(i ...interface{}){
+ if l.noShow {return}
if l.fileName == "" {log.Println("INFO:", i);return}
l.channelN <- 1
l.channel <- i
if len(l.wantLog) ==0 {l.wantLog <- true;l.wantLog <- true}
}
func (l *logl) W(i ...interface{}){
+ if l.noShow {return}
if l.fileName == "" {log.Println("WARNING:", i);return}
l.channelN <- 2
l.channel <- i
if len(l.wantLog) ==0 {l.wantLog <- true;l.wantLog <- true}
}
func (l *logl) E(i ...interface{}){
+ if l.noShow {return}
if l.fileName == "" {log.Println("ERROR:", i);return}
l.channelN <- 3
l.channel <- i