-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
432 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2020 Ye Zi Jie. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Email: [email protected] | ||
// Created at 2020/03/06 16:01:00 | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/FishGoddess/logit" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a logger holder. | ||
// Default handler is logit.DefaultLoggerHandler. | ||
logger := logit.NewLogger(os.Stdout, logit.InfoLevel) | ||
logger.Info("before logging...") | ||
|
||
// Customize your own handler. | ||
handlers1 := func(logger *logit.Logger, level logit.LoggerLevel, now time.Time, msg string) bool { | ||
logger.Writer().Write([]byte("handlers1: " + msg + "\n")) | ||
return true | ||
} | ||
|
||
handlers2 := func(logger *logit.Logger, level logit.LoggerLevel, now time.Time, msg string) bool { | ||
logger.Writer().Write([]byte("handlers2: " + msg + "\n")) | ||
return true | ||
} | ||
|
||
// Add handlers to logger. | ||
// There are three handlers in logger because logger has a default handler inside after creating. | ||
// See logit.DefaultLoggerHandler. | ||
logger.AddHandlers(handlers1, handlers2) | ||
fmt.Println("fmt =========================================") | ||
logger.Info("after adding handlers...") | ||
|
||
// Set handlers to logger. | ||
// There are two handlers in logger because the default handler inside was removed. | ||
logger.SetHandlers(handlers1, handlers2) | ||
fmt.Println("fmt =========================================") | ||
logger.Info("after setting handlers...") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.