github.com/hedzr/evendeep@v0.4.8/dbglog/lessmaplog_false.go (about)

     1  //go:build !moremaplog
     2  // +build !moremaplog
     3  
     4  package dbglog
     5  
     6  // MoreMapLog shows the buildtag 'moremaplog' is enabled or not.
     7  //
     8  // This flag is used for hedzr/evendeep package so that it can print
     9  // more debug logging messages when copying map struct.
    10  //
    11  // You may borrow the mechanism to dump the more verbose messages for
    12  // debugging purpose.
    13  const MoreMapLog = false
    14  
    15  var logValid = true
    16  
    17  // DisableLog can be used to disable dbglog.Log at runtime.
    18  //
    19  // It detects and prevent log output if buildtag 'moremaplog' present.
    20  //
    21  // To query the active state by calling ChildLogEnabled.
    22  //
    23  // The best practise for DisableLog is:
    24  //
    25  //    defer dbglog.DisableLog()()
    26  //    evendeep.CopyTo(...) // the verbose logging will be prevent even if buildtag 'verbose' defined.
    27  //
    28  func DisableLog() func()    { var sav = logValid; logValid = MoreMapLog; return func() { logValid = sav } }
    29  func ChildLogEnabled() bool { return logValid }