-
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: make plugin more easier to maintain #83
Merged
Merged
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
09b7e1c
refactor: add lua vm struct
bytemain 6f462ae
feat: support struct marshal
bytemain 9250116
feat: add more ctx
bytemain 5732fb5
fix: encoding tag map error
bytemain 620e1c0
feat: add logger
bytemain bad1f1e
feat: add debug flag
bytemain a9f4f03
fix: fix decode in mixed struct
bytemain 882bb9a
fix: unmarshal to interface is not work
bytemain 0edeb1d
feat: ctx use marshal
bytemain f99b172
feat: unmarshal hook result
bytemain 4dc97fe
ci: update test cases
bytemain d76a19c
test: streamline encoding unit test
bytemain f4b0631
Merge remote-tracking branch 'origin/main' into refactor/make-plugin-…
bytemain 4f7b5d3
chore: remove print
bytemain 1a98f94
test: add more testcases
bytemain 95afe00
chore: revert hook name enum
bytemain a0feebe
chore: add license
bytemain 92e7071
Merge remote-tracking branch 'origin/main' into refactor/make-plugin-…
bytemain 82d0e17
chore: update log message
bytemain 6617df1
refactor: add plugin module
bytemain f107888
refactor: add a vm file
bytemain cb64f1a
chore: update logger
bytemain 2cae92c
chore: add license
bytemain 29560d5
feat: support marshal nil
bytemain 7061f28
fix: preinstall should work
bytemain 4984ff0
fix: lua checksum
bytemain 37a961c
chore: update code
bytemain f43ddb9
refactor: unmarshal plugin info
bytemain ad6f9e8
chore: some modifications
aooohan 3729e40
mod: remove debug log in encoding func
aooohan 275bcdb
mod: Optimize function calls
aooohan 2d33ebf
bugfix
aooohan c44f873
mod
aooohan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 Han Li and contributors | ||
* | ||
* 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. | ||
*/ | ||
|
||
package logger | ||
|
||
import "fmt" | ||
|
||
type LoggerLevel int | ||
|
||
const ( | ||
ErrorLevel LoggerLevel = iota | ||
InfoLevel | ||
DebugLevel | ||
) | ||
|
||
var globalLevel = InfoLevel | ||
|
||
func SetLevel(_level LoggerLevel) { | ||
globalLevel = _level | ||
} | ||
|
||
func Log(level LoggerLevel, args ...interface{}) { | ||
if globalLevel >= level { | ||
fmt.Println(args...) | ||
} | ||
} | ||
|
||
func Logf(level LoggerLevel, message string, args ...interface{}) { | ||
if globalLevel >= level { | ||
fmt.Printf(message, args...) | ||
} | ||
} | ||
|
||
func Error(message string) { | ||
Log(ErrorLevel, message) | ||
} | ||
|
||
func Errorf(message string, args ...interface{}) { | ||
Logf(ErrorLevel, message, args...) | ||
} | ||
|
||
func Info(message string) { | ||
Log(InfoLevel, message) | ||
} | ||
|
||
func Infof(message string, args ...interface{}) { | ||
Logf(InfoLevel, message, args...) | ||
} | ||
|
||
func Debug(args ...interface{}) { | ||
Log(DebugLevel, args...) | ||
} | ||
|
||
func Debugf(message string, args ...interface{}) { | ||
Logf(DebugLevel, message, args...) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only worked when this flag before any subcommand,
related: #88