Skip to content

Commit

Permalink
部分方法私有
Browse files Browse the repository at this point in the history
  • Loading branch information
dongjunjie committed Jan 27, 2022
1 parent 5b11970 commit 4fa8c93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions console_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewConsoleTransport(allowLevel ...Level) *ConsoleTransport {
* @param {Level} level
* @return {*}
*/
func (c *ConsoleTransport) ShouldLog(level Level) bool {
func (c *ConsoleTransport) shouldLog(level Level) bool {
for _, v := range c.allowLevel {
if v == level {
return true
Expand All @@ -40,7 +40,7 @@ func (c *ConsoleTransport) ShouldLog(level Level) bool {
* @param {*LogInfo} log
* @return {*}
*/
func (c *ConsoleTransport) Log(log *LogInfo) {
func (c *ConsoleTransport) log(log *LogInfo) {
logStr := formatConsole(log)
if log.Level == string(Error) {
fmt.Fprintln(os.Stderr, logStr)
Expand Down
4 changes: 2 additions & 2 deletions http_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (h *HttpTransport) SetMaxBufferSize(size int64) {
* @param {Level} level
* @return {*}
*/
func (h *HttpTransport) ShouldLog(level Level) bool {
func (h *HttpTransport) shouldLog(level Level) bool {
for _, v := range h.allowLevel {
if v == level {
return true
Expand All @@ -109,7 +109,7 @@ func (h *HttpTransport) ShouldLog(level Level) bool {
* @param {*LogInfo} log
* @return {*}
*/
func (h *HttpTransport) Log(log *LogInfo) {
func (h *HttpTransport) log(log *LogInfo) {
logStr := formatHttp(log)
h.bufferChan <- logStr
}
Expand Down
10 changes: 5 additions & 5 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,20 @@ func (l *Logger) log(level Level, message string) {
for _, item := range l.transport {
switch v := item.(type) {
case *HttpTransport:
if v.ShouldLog(level) {
if v.shouldLog(level) {
isLog = true
v.Log(logInfo)
v.log(logInfo)
}
case *ConsoleTransport:
if v.ShouldLog(level) {
if v.shouldLog(level) {
isLog = true
v.Log(logInfo)
v.log(logInfo)
}
}
}

if !isLog {
consoleTransport := NewConsoleTransport()
consoleTransport.Log(logInfo)
consoleTransport.log(logInfo)
}
}

0 comments on commit 4fa8c93

Please sign in to comment.