example.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2013, Cong Ding. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // author: Cong Ding <dinggnu@gmail.com>
  16. package main
  17. import (
  18. "github.com/ccding/go-logging/logging"
  19. "time"
  20. )
  21. func main() {
  22. logger1, _ := logging.SimpleLogger("logger1")
  23. logger1.SetLevel(logging.NOTSET)
  24. logger1.Error("this is a test from error")
  25. logger1.Debug("this is a test from debug")
  26. logger1.Notset("orz", time.Now().UnixNano())
  27. logger1.Destroy()
  28. logger2, _ := logging.RichLogger("logger2")
  29. logger2.SetLevel(logging.DEBUG)
  30. logger2.Error("this is a test from error")
  31. logger2.Debug("this is a test from debug")
  32. logger2.Notset("orz", time.Now().UnixNano())
  33. logger2.Destroy()
  34. logger3, _ := logging.ConfigLogger("example.conf")
  35. logger3.SetLevel(logging.DEBUG)
  36. logger3.Error("this is a test from error")
  37. logger3.Debug("this is a test from debug")
  38. logger3.Notset("orz", time.Now().UnixNano())
  39. logger3.Destroy()
  40. }