commands.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. //
  17. package logging
  18. // Logln receives log request from the client. The request includes a set of
  19. // variables.
  20. func (logger *Logger) Log(level Level, v ...interface{}) {
  21. // Don't delete this calling. The calling is used to keep the same
  22. // calldepth for all the logging functions. The calldepth is used to
  23. // get runtime information such as line number, function name, etc.
  24. logger.log(level, v...)
  25. }
  26. // Logf receives log request from the client. The request has a string
  27. // parameter to describe the format of output.
  28. func (logger *Logger) Logf(level Level, format string, v ...interface{}) {
  29. logger.logf(level, format, v...)
  30. }
  31. // Other quick commands for different level
  32. func (logger *Logger) Critical(v ...interface{}) {
  33. logger.log(CRITICAL, v...)
  34. }
  35. func (logger *Logger) Fatal(v ...interface{}) {
  36. logger.log(CRITICAL, v...)
  37. }
  38. func (logger *Logger) Error(v ...interface{}) {
  39. logger.log(ERROR, v...)
  40. }
  41. func (logger *Logger) Warn(v ...interface{}) {
  42. logger.log(WARNING, v...)
  43. }
  44. func (logger *Logger) Warning(v ...interface{}) {
  45. logger.log(WARNING, v...)
  46. }
  47. func (logger *Logger) Info(v ...interface{}) {
  48. logger.log(INFO, v...)
  49. }
  50. func (logger *Logger) Debug(v ...interface{}) {
  51. logger.log(DEBUG, v...)
  52. }
  53. func (logger *Logger) Notset(v ...interface{}) {
  54. logger.log(NOTSET, v...)
  55. }
  56. func (logger *Logger) Criticalf(format string, v ...interface{}) {
  57. logger.logf(CRITICAL, format, v...)
  58. }
  59. func (logger *Logger) Fatalf(format string, v ...interface{}) {
  60. logger.logf(CRITICAL, format, v...)
  61. }
  62. func (logger *Logger) Errorf(format string, v ...interface{}) {
  63. logger.logf(ERROR, format, v...)
  64. }
  65. func (logger *Logger) Warnf(format string, v ...interface{}) {
  66. logger.logf(WARNING, format, v...)
  67. }
  68. func (logger *Logger) Warningf(format string, v ...interface{}) {
  69. logger.logf(WARNING, format, v...)
  70. }
  71. func (logger *Logger) Infof(format string, v ...interface{}) {
  72. logger.logf(INFO, format, v...)
  73. }
  74. func (logger *Logger) Debugf(format string, v ...interface{}) {
  75. logger.logf(DEBUG, format, v...)
  76. }
  77. func (logger *Logger) Notsetf(format string, v ...interface{}) {
  78. logger.logf(NOTSET, format, v...)
  79. }