mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For regression test, add srs-bench to 3rdparty
This commit is contained in:
parent
de87dd427d
commit
876210f6c9
1158 changed files with 256967 additions and 3 deletions
13
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/.golangci.yml
generated
vendored
Normal file
13
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/.golangci.yml
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
misspell:
|
||||
locale: US
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
max-per-linter: 0
|
||||
max-same-issues: 50
|
19
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/.travis.yml
generated
vendored
Normal file
19
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- "1.x" # use the latest Go release
|
||||
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
|
||||
before_script:
|
||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0
|
||||
|
||||
script:
|
||||
- golangci-lint run ./...
|
||||
# - rm -rf examples # Remove examples, no test coverage for them
|
||||
- go test -coverpkg=$(go list ./... | tr '\n' ',') -coverprofile=cover.out -v -race -covermode=atomic ./...
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
- bash .github/assert-contributors.sh
|
||||
- bash .github/lint-disallowed-functions-in-library.sh
|
||||
- bash .github/lint-commit-message.sh
|
21
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/LICENSE
generated
vendored
Normal file
21
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
41
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/README.md
generated
vendored
Normal file
41
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/README.md
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
<h1 align="center">
|
||||
<br>
|
||||
Pion Logging
|
||||
<br>
|
||||
</h1>
|
||||
<h4 align="center">The Pion logging library</h4>
|
||||
<p align="center">
|
||||
<a href="https://pion.ly"><img src="https://img.shields.io/badge/pion-logging-gray.svg?longCache=true&colorB=brightgreen" alt="Pion transport"></a>
|
||||
<a href="http://gophers.slack.com/messages/pion"><img src="https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&logo=slack&colorB=brightgreen" alt="Slack Widget"></a>
|
||||
<br>
|
||||
<a href="https://travis-ci.org/pion/logging"><img src="https://travis-ci.org/pion/logging.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://godoc.org/github.com/pion/logging"><img src="https://godoc.org/github.com/pion/logging?status.svg" alt="GoDoc"></a>
|
||||
<a href="https://codecov.io/gh/pion/logging"><img src="https://codecov.io/gh/pion/logging/branch/master/graph/badge.svg" alt="Coverage Status"></a>
|
||||
<a href="https://goreportcard.com/report/github.com/pion/logging"><img src="https://goreportcard.com/badge/github.com/pion/logging" alt="Go Report Card"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
||||
</p>
|
||||
<br>
|
||||
|
||||
### Roadmap
|
||||
The library is used as a part of our WebRTC implementation. Please refer to that [roadmap](https://github.com/pion/webrtc/issues/9) to track our major milestones.
|
||||
|
||||
### Community
|
||||
Pion has an active community on the [Golang Slack](https://invite.slack.golangbridge.org/). Sign up and join the **#pion** channel for discussions and support. You can also use [Pion mailing list](https://groups.google.com/forum/#!forum/pion).
|
||||
|
||||
We are always looking to support **your projects**. Please reach out if you have something to build!
|
||||
|
||||
If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly)
|
||||
|
||||
### Contributing
|
||||
Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible:
|
||||
|
||||
* [John Bradley](https://github.com/kc5nra) - *Original Author*
|
||||
* [Sean DuBois](https://github.com/Sean-Der) - *Original Author*
|
||||
* [Michael MacDonald](https://github.com/mjmac) - *Original Author*
|
||||
* [Woodrow Douglass](https://github.com/wdouglass) - *Test coverage*
|
||||
* [Michiel De Backker](https://github.com/backkem) - *Docs*
|
||||
* [Hugo Arregui](https://github.com/hugoArregui) - *Custom Logs*
|
||||
* [Justin Okamoto](https://github.com/justinokamoto) - *Disabled Logs Update*
|
||||
|
||||
### License
|
||||
MIT License - see [LICENSE](LICENSE) for full text
|
3
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/go.mod
generated
vendored
Normal file
3
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/pion/logging
|
||||
|
||||
go 1.12
|
0
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/go.sum
generated
vendored
Normal file
0
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/go.sum
generated
vendored
Normal file
228
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/logger.go
generated
vendored
Normal file
228
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/logger.go
generated
vendored
Normal file
|
@ -0,0 +1,228 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Use this abstraction to ensure thread-safe access to the logger's io.Writer
|
||||
// (which could change at runtime)
|
||||
type loggerWriter struct {
|
||||
sync.RWMutex
|
||||
output io.Writer
|
||||
}
|
||||
|
||||
func (lw *loggerWriter) SetOutput(output io.Writer) {
|
||||
lw.Lock()
|
||||
defer lw.Unlock()
|
||||
lw.output = output
|
||||
}
|
||||
|
||||
func (lw *loggerWriter) Write(data []byte) (int, error) {
|
||||
lw.RLock()
|
||||
defer lw.RUnlock()
|
||||
return lw.output.Write(data)
|
||||
}
|
||||
|
||||
// DefaultLeveledLogger encapsulates functionality for providing logging at
|
||||
// user-defined levels
|
||||
type DefaultLeveledLogger struct {
|
||||
level LogLevel
|
||||
writer *loggerWriter
|
||||
trace *log.Logger
|
||||
debug *log.Logger
|
||||
info *log.Logger
|
||||
warn *log.Logger
|
||||
err *log.Logger
|
||||
}
|
||||
|
||||
// WithTraceLogger is a chainable configuration function which sets the
|
||||
// Trace-level logger
|
||||
func (ll *DefaultLeveledLogger) WithTraceLogger(log *log.Logger) *DefaultLeveledLogger {
|
||||
ll.trace = log
|
||||
return ll
|
||||
}
|
||||
|
||||
// WithDebugLogger is a chainable configuration function which sets the
|
||||
// Debug-level logger
|
||||
func (ll *DefaultLeveledLogger) WithDebugLogger(log *log.Logger) *DefaultLeveledLogger {
|
||||
ll.debug = log
|
||||
return ll
|
||||
}
|
||||
|
||||
// WithInfoLogger is a chainable configuration function which sets the
|
||||
// Info-level logger
|
||||
func (ll *DefaultLeveledLogger) WithInfoLogger(log *log.Logger) *DefaultLeveledLogger {
|
||||
ll.info = log
|
||||
return ll
|
||||
}
|
||||
|
||||
// WithWarnLogger is a chainable configuration function which sets the
|
||||
// Warn-level logger
|
||||
func (ll *DefaultLeveledLogger) WithWarnLogger(log *log.Logger) *DefaultLeveledLogger {
|
||||
ll.warn = log
|
||||
return ll
|
||||
}
|
||||
|
||||
// WithErrorLogger is a chainable configuration function which sets the
|
||||
// Error-level logger
|
||||
func (ll *DefaultLeveledLogger) WithErrorLogger(log *log.Logger) *DefaultLeveledLogger {
|
||||
ll.err = log
|
||||
return ll
|
||||
}
|
||||
|
||||
// WithOutput is a chainable configuration function which sets the logger's
|
||||
// logging output to the supplied io.Writer
|
||||
func (ll *DefaultLeveledLogger) WithOutput(output io.Writer) *DefaultLeveledLogger {
|
||||
ll.writer.SetOutput(output)
|
||||
return ll
|
||||
}
|
||||
|
||||
func (ll *DefaultLeveledLogger) logf(logger *log.Logger, level LogLevel, format string, args ...interface{}) {
|
||||
if ll.level.Get() < level {
|
||||
return
|
||||
}
|
||||
|
||||
callDepth := 3 // this frame + wrapper func + caller
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
if err := logger.Output(callDepth, msg); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to log: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// SetLevel sets the logger's logging level
|
||||
func (ll *DefaultLeveledLogger) SetLevel(newLevel LogLevel) {
|
||||
ll.level.Set(newLevel)
|
||||
}
|
||||
|
||||
// Trace emits the preformatted message if the logger is at or below LogLevelTrace
|
||||
func (ll *DefaultLeveledLogger) Trace(msg string) {
|
||||
ll.logf(ll.trace, LogLevelTrace, msg)
|
||||
}
|
||||
|
||||
// Tracef formats and emits a message if the logger is at or below LogLevelTrace
|
||||
func (ll *DefaultLeveledLogger) Tracef(format string, args ...interface{}) {
|
||||
ll.logf(ll.trace, LogLevelTrace, format, args...)
|
||||
}
|
||||
|
||||
// Debug emits the preformatted message if the logger is at or below LogLevelDebug
|
||||
func (ll *DefaultLeveledLogger) Debug(msg string) {
|
||||
ll.logf(ll.debug, LogLevelDebug, msg)
|
||||
}
|
||||
|
||||
// Debugf formats and emits a message if the logger is at or below LogLevelDebug
|
||||
func (ll *DefaultLeveledLogger) Debugf(format string, args ...interface{}) {
|
||||
ll.logf(ll.debug, LogLevelDebug, format, args...)
|
||||
}
|
||||
|
||||
// Info emits the preformatted message if the logger is at or below LogLevelInfo
|
||||
func (ll *DefaultLeveledLogger) Info(msg string) {
|
||||
ll.logf(ll.info, LogLevelInfo, msg)
|
||||
}
|
||||
|
||||
// Infof formats and emits a message if the logger is at or below LogLevelInfo
|
||||
func (ll *DefaultLeveledLogger) Infof(format string, args ...interface{}) {
|
||||
ll.logf(ll.info, LogLevelInfo, format, args...)
|
||||
}
|
||||
|
||||
// Warn emits the preformatted message if the logger is at or below LogLevelWarn
|
||||
func (ll *DefaultLeveledLogger) Warn(msg string) {
|
||||
ll.logf(ll.warn, LogLevelWarn, msg)
|
||||
}
|
||||
|
||||
// Warnf formats and emits a message if the logger is at or below LogLevelWarn
|
||||
func (ll *DefaultLeveledLogger) Warnf(format string, args ...interface{}) {
|
||||
ll.logf(ll.warn, LogLevelWarn, format, args...)
|
||||
}
|
||||
|
||||
// Error emits the preformatted message if the logger is at or below LogLevelError
|
||||
func (ll *DefaultLeveledLogger) Error(msg string) {
|
||||
ll.logf(ll.err, LogLevelError, msg)
|
||||
}
|
||||
|
||||
// Errorf formats and emits a message if the logger is at or below LogLevelError
|
||||
func (ll *DefaultLeveledLogger) Errorf(format string, args ...interface{}) {
|
||||
ll.logf(ll.err, LogLevelError, format, args...)
|
||||
}
|
||||
|
||||
// NewDefaultLeveledLoggerForScope returns a configured LeveledLogger
|
||||
func NewDefaultLeveledLoggerForScope(scope string, level LogLevel, writer io.Writer) *DefaultLeveledLogger {
|
||||
if writer == nil {
|
||||
writer = os.Stdout
|
||||
}
|
||||
logger := &DefaultLeveledLogger{
|
||||
writer: &loggerWriter{output: writer},
|
||||
level: level,
|
||||
}
|
||||
return logger.
|
||||
WithTraceLogger(log.New(logger.writer, fmt.Sprintf("%s TRACE: ", scope), log.Lmicroseconds|log.Lshortfile)).
|
||||
WithDebugLogger(log.New(logger.writer, fmt.Sprintf("%s DEBUG: ", scope), log.Lmicroseconds|log.Lshortfile)).
|
||||
WithInfoLogger(log.New(logger.writer, fmt.Sprintf("%s INFO: ", scope), log.LstdFlags)).
|
||||
WithWarnLogger(log.New(logger.writer, fmt.Sprintf("%s WARNING: ", scope), log.LstdFlags)).
|
||||
WithErrorLogger(log.New(logger.writer, fmt.Sprintf("%s ERROR: ", scope), log.LstdFlags))
|
||||
}
|
||||
|
||||
// DefaultLoggerFactory define levels by scopes and creates new DefaultLeveledLogger
|
||||
type DefaultLoggerFactory struct {
|
||||
Writer io.Writer
|
||||
DefaultLogLevel LogLevel
|
||||
ScopeLevels map[string]LogLevel
|
||||
}
|
||||
|
||||
// NewDefaultLoggerFactory creates a new DefaultLoggerFactory
|
||||
func NewDefaultLoggerFactory() *DefaultLoggerFactory {
|
||||
factory := DefaultLoggerFactory{}
|
||||
factory.DefaultLogLevel = LogLevelError
|
||||
factory.ScopeLevels = make(map[string]LogLevel)
|
||||
factory.Writer = os.Stdout
|
||||
|
||||
logLevels := map[string]LogLevel{
|
||||
"DISABLE": LogLevelDisabled,
|
||||
"ERROR": LogLevelError,
|
||||
"WARN": LogLevelWarn,
|
||||
"INFO": LogLevelInfo,
|
||||
"DEBUG": LogLevelDebug,
|
||||
"TRACE": LogLevelTrace,
|
||||
}
|
||||
|
||||
for name, level := range logLevels {
|
||||
env := os.Getenv(fmt.Sprintf("PION_LOG_%s", name))
|
||||
|
||||
if env == "" {
|
||||
env = os.Getenv(fmt.Sprintf("PIONS_LOG_%s", name))
|
||||
}
|
||||
|
||||
if env == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.ToLower(env) == "all" {
|
||||
factory.DefaultLogLevel = level
|
||||
continue
|
||||
}
|
||||
|
||||
scopes := strings.Split(strings.ToLower(env), ",")
|
||||
for _, scope := range scopes {
|
||||
factory.ScopeLevels[scope] = level
|
||||
}
|
||||
}
|
||||
|
||||
return &factory
|
||||
}
|
||||
|
||||
// NewLogger returns a configured LeveledLogger for the given , argsscope
|
||||
func (f *DefaultLoggerFactory) NewLogger(scope string) LeveledLogger {
|
||||
logLevel := f.DefaultLogLevel
|
||||
if f.ScopeLevels != nil {
|
||||
scopeLevel, found := f.ScopeLevels[scope]
|
||||
|
||||
if found {
|
||||
logLevel = scopeLevel
|
||||
}
|
||||
}
|
||||
return NewDefaultLeveledLoggerForScope(scope, logLevel, f.Writer)
|
||||
}
|
72
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/scoped.go
generated
vendored
Normal file
72
trunk/3rdparty/srs-bench/vendor/github.com/pion/logging/scoped.go
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// LogLevel represents the level at which the logger will emit log messages
|
||||
type LogLevel int32
|
||||
|
||||
// Set updates the LogLevel to the supplied value
|
||||
func (ll *LogLevel) Set(newLevel LogLevel) {
|
||||
atomic.StoreInt32((*int32)(ll), int32(newLevel))
|
||||
}
|
||||
|
||||
// Get retrieves the current LogLevel value
|
||||
func (ll *LogLevel) Get() LogLevel {
|
||||
return LogLevel(atomic.LoadInt32((*int32)(ll)))
|
||||
}
|
||||
|
||||
func (ll LogLevel) String() string {
|
||||
switch ll {
|
||||
case LogLevelDisabled:
|
||||
return "Disabled"
|
||||
case LogLevelError:
|
||||
return "Error"
|
||||
case LogLevelWarn:
|
||||
return "Warn"
|
||||
case LogLevelInfo:
|
||||
return "Info"
|
||||
case LogLevelDebug:
|
||||
return "Debug"
|
||||
case LogLevelTrace:
|
||||
return "Trace"
|
||||
default:
|
||||
return "UNKNOWN"
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
// LogLevelDisabled completely disables logging of any events
|
||||
LogLevelDisabled LogLevel = iota
|
||||
// LogLevelError is for fatal errors which should be handled by user code,
|
||||
// but are logged to ensure that they are seen
|
||||
LogLevelError
|
||||
// LogLevelWarn is for logging abnormal, but non-fatal library operation
|
||||
LogLevelWarn
|
||||
// LogLevelInfo is for logging normal library operation (e.g. state transitions, etc.)
|
||||
LogLevelInfo
|
||||
// LogLevelDebug is for logging low-level library information (e.g. internal operations)
|
||||
LogLevelDebug
|
||||
// LogLevelTrace is for logging very low-level library information (e.g. network traces)
|
||||
LogLevelTrace
|
||||
)
|
||||
|
||||
// LeveledLogger is the basic pion Logger interface
|
||||
type LeveledLogger interface {
|
||||
Trace(msg string)
|
||||
Tracef(format string, args ...interface{})
|
||||
Debug(msg string)
|
||||
Debugf(format string, args ...interface{})
|
||||
Info(msg string)
|
||||
Infof(format string, args ...interface{})
|
||||
Warn(msg string)
|
||||
Warnf(format string, args ...interface{})
|
||||
Error(msg string)
|
||||
Errorf(format string, args ...interface{})
|
||||
}
|
||||
|
||||
// LoggerFactory is the basic pion LoggerFactory interface
|
||||
type LoggerFactory interface {
|
||||
NewLogger(scope string) LeveledLogger
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue