github.com/gogf/gf/v2@v2.7.4/os/glog/glog_chaining.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/gogf/gf.
     6  
     7  package glog
     8  
     9  import (
    10  	"io"
    11  )
    12  
    13  // Expose returns the default logger of package glog.
    14  func Expose() *Logger {
    15  	return defaultLogger
    16  }
    17  
    18  // To is a chaining function,
    19  // which redirects current logging content output to the sepecified `writer`.
    20  func To(writer io.Writer) *Logger {
    21  	return defaultLogger.To(writer)
    22  }
    23  
    24  // Path is a chaining function,
    25  // which sets the directory path to `path` for current logging content output.
    26  func Path(path string) *Logger {
    27  	return defaultLogger.Path(path)
    28  }
    29  
    30  // Cat is a chaining function,
    31  // which sets the category to `category` for current logging content output.
    32  func Cat(category string) *Logger {
    33  	return defaultLogger.Cat(category)
    34  }
    35  
    36  // File is a chaining function,
    37  // which sets file name `pattern` for the current logging content output.
    38  func File(pattern string) *Logger {
    39  	return defaultLogger.File(pattern)
    40  }
    41  
    42  // Level is a chaining function,
    43  // which sets logging level for the current logging content output.
    44  func Level(level int) *Logger {
    45  	return defaultLogger.Level(level)
    46  }
    47  
    48  // LevelStr is a chaining function,
    49  // which sets logging level for the current logging content output using level string.
    50  func LevelStr(levelStr string) *Logger {
    51  	return defaultLogger.LevelStr(levelStr)
    52  }
    53  
    54  // Skip is a chaining function,
    55  // which sets stack skip for the current logging content output.
    56  // It also affects the caller file path checks when line number printing enabled.
    57  func Skip(skip int) *Logger {
    58  	return defaultLogger.Skip(skip)
    59  }
    60  
    61  // Stack is a chaining function,
    62  // which sets stack options for the current logging content output .
    63  func Stack(enabled bool, skip ...int) *Logger {
    64  	return defaultLogger.Stack(enabled, skip...)
    65  }
    66  
    67  // StackWithFilter is a chaining function,
    68  // which sets stack filter for the current logging content output .
    69  func StackWithFilter(filter string) *Logger {
    70  	return defaultLogger.StackWithFilter(filter)
    71  }
    72  
    73  // Stdout is a chaining function,
    74  // which enables/disables stdout for the current logging content output.
    75  // It's enabled in default.
    76  func Stdout(enabled ...bool) *Logger {
    77  	return defaultLogger.Stdout(enabled...)
    78  }
    79  
    80  // Header is a chaining function,
    81  // which enables/disables log header for the current logging content output.
    82  // It's enabled in default.
    83  func Header(enabled ...bool) *Logger {
    84  	return defaultLogger.Header(enabled...)
    85  }
    86  
    87  // Line is a chaining function,
    88  // which enables/disables printing its caller file along with its line number.
    89  // The parameter `long` specified whether print the long absolute file path, eg: /a/b/c/d.go:23.
    90  func Line(long ...bool) *Logger {
    91  	return defaultLogger.Line(long...)
    92  }
    93  
    94  // Async is a chaining function,
    95  // which enables/disables async logging output feature.
    96  func Async(enabled ...bool) *Logger {
    97  	return defaultLogger.Async(enabled...)
    98  }