id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
17,000
spacemonkeygo/spacelog
convenience.go
Errore
func (l *Logger) Errore(err error) { if l.getLevel() <= Error && err != nil { l.getHandler().Log(l.name, Error, err.Error(), 1) } }
go
func (l *Logger) Errore(err error) { if l.getLevel() <= Error && err != nil { l.getHandler().Log(l.name, Error, err.Error(), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Errore", "(", "err", "error", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "Error", "&&", "err", "!=", "nil", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ".", "name", ",", "Erro...
// Errore logs an error value if the error is not nil and the logger's level // is error or even more permissive.
[ "Errore", "logs", "an", "error", "value", "if", "the", "error", "is", "not", "nil", "and", "the", "logger", "s", "level", "is", "error", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L190-L194
17,001
spacemonkeygo/spacelog
convenience.go
Crit
func (l *Logger) Crit(v ...interface{}) { if l.getLevel() <= Critical { l.getHandler().Log(l.name, Critical, fmt.Sprint(v...), 1) } }
go
func (l *Logger) Crit(v ...interface{}) { if l.getLevel() <= Critical { l.getHandler().Log(l.name, Critical, fmt.Sprint(v...), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Crit", "(", "v", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "Critical", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ".", "name", ",", "Critical", ...
// Crit logs a collection of values if the logger's level is critical or even // more permissive.
[ "Crit", "logs", "a", "collection", "of", "values", "if", "the", "logger", "s", "level", "is", "critical", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L204-L208
17,002
spacemonkeygo/spacelog
convenience.go
Critf
func (l *Logger) Critf(format string, v ...interface{}) { if l.getLevel() <= Critical { l.getHandler().Log(l.name, Critical, fmt.Sprintf(format, v...), 1) } }
go
func (l *Logger) Critf(format string, v ...interface{}) { if l.getLevel() <= Critical { l.getHandler().Log(l.name, Critical, fmt.Sprintf(format, v...), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Critf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "Critical", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ".", ...
// Critf logs a format string with values if the logger's level is critical or // even more permissive.
[ "Critf", "logs", "a", "format", "string", "with", "values", "if", "the", "logger", "s", "level", "is", "critical", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L212-L216
17,003
spacemonkeygo/spacelog
convenience.go
Crite
func (l *Logger) Crite(err error) { if l.getLevel() <= Critical && err != nil { l.getHandler().Log(l.name, Critical, err.Error(), 1) } }
go
func (l *Logger) Crite(err error) { if l.getLevel() <= Critical && err != nil { l.getHandler().Log(l.name, Critical, err.Error(), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Crite", "(", "err", "error", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "Critical", "&&", "err", "!=", "nil", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ".", "name", ",", "Cr...
// Crite logs an error value if the error is not nil and the logger's level // is critical or even more permissive.
[ "Crite", "logs", "an", "error", "value", "if", "the", "error", "is", "not", "nil", "and", "the", "logger", "s", "level", "is", "critical", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L220-L224
17,004
spacemonkeygo/spacelog
convenience.go
Log
func (l *Logger) Log(level LogLevel, v ...interface{}) { if l.getLevel() <= level { l.getHandler().Log(l.name, level, fmt.Sprint(v...), 1) } }
go
func (l *Logger) Log(level LogLevel, v ...interface{}) { if l.getLevel() <= level { l.getHandler().Log(l.name, level, fmt.Sprint(v...), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Log", "(", "level", "LogLevel", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "level", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ".", "n...
// Log logs a collection of values if the logger's level is the provided level // or even more permissive.
[ "Log", "logs", "a", "collection", "of", "values", "if", "the", "logger", "s", "level", "is", "the", "provided", "level", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L234-L238
17,005
spacemonkeygo/spacelog
convenience.go
Logf
func (l *Logger) Logf(level LogLevel, format string, v ...interface{}) { if l.getLevel() <= level { l.getHandler().Log(l.name, level, fmt.Sprintf(format, v...), 1) } }
go
func (l *Logger) Logf(level LogLevel, format string, v ...interface{}) { if l.getLevel() <= level { l.getHandler().Log(l.name, level, fmt.Sprintf(format, v...), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Logf", "(", "level", "LogLevel", ",", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "level", "{", "l", ".", "getHandler", "(", ")", ".", ...
// Logf logs a format string with values if the logger's level is the provided // level or even more permissive.
[ "Logf", "logs", "a", "format", "string", "with", "values", "if", "the", "logger", "s", "level", "is", "the", "provided", "level", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L242-L246
17,006
spacemonkeygo/spacelog
convenience.go
Loge
func (l *Logger) Loge(level LogLevel, err error) { if l.getLevel() <= level && err != nil { l.getHandler().Log(l.name, level, err.Error(), 1) } }
go
func (l *Logger) Loge(level LogLevel, err error) { if l.getLevel() <= level && err != nil { l.getHandler().Log(l.name, level, err.Error(), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Loge", "(", "level", "LogLevel", ",", "err", "error", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "level", "&&", "err", "!=", "nil", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ...
// Loge logs an error value if the error is not nil and the logger's level // is the provided level or even more permissive.
[ "Loge", "logs", "an", "error", "value", "if", "the", "error", "is", "not", "nil", "and", "the", "logger", "s", "level", "is", "the", "provided", "level", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L250-L254
17,007
spacemonkeygo/spacelog
convenience.go
Writer
func (l *Logger) Writer(level LogLevel) io.Writer { return &writer{l: l, level: level} }
go
func (l *Logger) Writer(level LogLevel) io.Writer { return &writer{l: l, level: level} }
[ "func", "(", "l", "*", "Logger", ")", "Writer", "(", "level", "LogLevel", ")", "io", ".", "Writer", "{", "return", "&", "writer", "{", "l", ":", "l", ",", "level", ":", "level", "}", "\n", "}" ]
// Writer returns an io.Writer that writes messages at the given log level.
[ "Writer", "returns", "an", "io", ".", "Writer", "that", "writes", "messages", "at", "the", "given", "log", "level", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L275-L277
17,008
spacemonkeygo/spacelog
convenience.go
WriterWithoutCaller
func (l *Logger) WriterWithoutCaller(level LogLevel) io.Writer { return &writerNoCaller{l: l, level: level} }
go
func (l *Logger) WriterWithoutCaller(level LogLevel) io.Writer { return &writerNoCaller{l: l, level: level} }
[ "func", "(", "l", "*", "Logger", ")", "WriterWithoutCaller", "(", "level", "LogLevel", ")", "io", ".", "Writer", "{", "return", "&", "writerNoCaller", "{", "l", ":", "l", ",", "level", ":", "level", "}", "\n", "}" ]
// WriterWithoutCaller returns an io.Writer that writes messages at the given // log level, but does not attempt to collect the Write caller, and provides // no caller information to the log event.
[ "WriterWithoutCaller", "returns", "an", "io", ".", "Writer", "that", "writes", "messages", "at", "the", "given", "log", "level", "but", "does", "not", "attempt", "to", "collect", "the", "Write", "caller", "and", "provides", "no", "caller", "information", "to",...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L294-L296
17,009
spacemonkeygo/spacelog
collection.go
NewLoggerCollection
func NewLoggerCollection() *LoggerCollection { return &LoggerCollection{ loggers: make(map[string]*Logger), level: DefaultLevel, handler: defaultHandler} }
go
func NewLoggerCollection() *LoggerCollection { return &LoggerCollection{ loggers: make(map[string]*Logger), level: DefaultLevel, handler: defaultHandler} }
[ "func", "NewLoggerCollection", "(", ")", "*", "LoggerCollection", "{", "return", "&", "LoggerCollection", "{", "loggers", ":", "make", "(", "map", "[", "string", "]", "*", "Logger", ")", ",", "level", ":", "DefaultLevel", ",", "handler", ":", "defaultHandler...
// NewLoggerCollection creates a new logger collection. It's unlikely you will // ever practically need this method. Use the DefaultLoggerCollection instead.
[ "NewLoggerCollection", "creates", "a", "new", "logger", "collection", ".", "It", "s", "unlikely", "you", "will", "ever", "practically", "need", "this", "method", ".", "Use", "the", "DefaultLoggerCollection", "instead", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L61-L66
17,010
spacemonkeygo/spacelog
collection.go
GetLoggerNamed
func (c *LoggerCollection) GetLoggerNamed(name string) *Logger { c.mtx.Lock() defer c.mtx.Unlock() logger, exists := c.loggers[name] if !exists { logger = &Logger{level: c.level, collection: c, name: name, handler: c.handler} c.loggers[name] = logger } return logger }
go
func (c *LoggerCollection) GetLoggerNamed(name string) *Logger { c.mtx.Lock() defer c.mtx.Unlock() logger, exists := c.loggers[name] if !exists { logger = &Logger{level: c.level, collection: c, name: name, handler: c.handler} c.loggers[name] = logger } return logger }
[ "func", "(", "c", "*", "LoggerCollection", ")", "GetLoggerNamed", "(", "name", "string", ")", "*", "Logger", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "logger", ",", "exists", ":="...
// GetLoggerNamed returns a new Logger with the provided name. GetLogger is // more frequently used.
[ "GetLoggerNamed", "returns", "a", "new", "Logger", "with", "the", "provided", "name", ".", "GetLogger", "is", "more", "frequently", "used", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L122-L135
17,011
spacemonkeygo/spacelog
collection.go
SetLevel
func (c *LoggerCollection) SetLevel(re *regexp.Regexp, level LogLevel) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.level = level } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.setLevel(level) } } }
go
func (c *LoggerCollection) SetLevel(re *regexp.Regexp, level LogLevel) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.level = level } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.setLevel(level) } } }
[ "func", "(", "c", "*", "LoggerCollection", ")", "SetLevel", "(", "re", "*", "regexp", ".", "Regexp", ",", "level", "LogLevel", ")", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if"...
// SetLevel will set the current log level for all loggers with names that // match a provided regular expression. If the regular expression is nil, then // all loggers match.
[ "SetLevel", "will", "set", "the", "current", "log", "level", "for", "all", "loggers", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", "nil", "then", "all", "loggers", "match", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L140-L152
17,012
spacemonkeygo/spacelog
collection.go
SetHandler
func (c *LoggerCollection) SetHandler(re *regexp.Regexp, handler Handler) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.handler = handler } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.setHandler(handler) } } }
go
func (c *LoggerCollection) SetHandler(re *regexp.Regexp, handler Handler) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.handler = handler } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.setHandler(handler) } } }
[ "func", "(", "c", "*", "LoggerCollection", ")", "SetHandler", "(", "re", "*", "regexp", ".", "Regexp", ",", "handler", "Handler", ")", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "...
// SetHandler will set the current log handler for all loggers with names that // match a provided regular expression. If the regular expression is nil, then // all loggers match.
[ "SetHandler", "will", "set", "the", "current", "log", "handler", "for", "all", "loggers", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", "nil", "then", "all", "loggers", "match", "...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L157-L169
17,013
spacemonkeygo/spacelog
collection.go
SetTextTemplate
func (c *LoggerCollection) SetTextTemplate(re *regexp.Regexp, t *template.Template) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.handler.SetTextTemplate(t) } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.getHandler().SetTextTemplate(t) } } }
go
func (c *LoggerCollection) SetTextTemplate(re *regexp.Regexp, t *template.Template) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.handler.SetTextTemplate(t) } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.getHandler().SetTextTemplate(t) } } }
[ "func", "(", "c", "*", "LoggerCollection", ")", "SetTextTemplate", "(", "re", "*", "regexp", ".", "Regexp", ",", "t", "*", "template", ".", "Template", ")", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock",...
// SetTextTemplate will set the current text template for all loggers with // names that match a provided regular expression. If the regular expression // is nil, then all loggers match. Note that not every handler is guaranteed // to support text templates and a text template will only apply to // text-oriented and unstructured handlers.
[ "SetTextTemplate", "will", "set", "the", "current", "text", "template", "for", "all", "loggers", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", "nil", "then", "all", "loggers", "matc...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L176-L189
17,014
spacemonkeygo/spacelog
collection.go
SetTextOutput
func (c *LoggerCollection) SetTextOutput(re *regexp.Regexp, output TextOutput) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.handler.SetTextOutput(output) } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.getHandler().SetTextOutput(output) } } }
go
func (c *LoggerCollection) SetTextOutput(re *regexp.Regexp, output TextOutput) { c.mtx.Lock() defer c.mtx.Unlock() if re == nil { c.handler.SetTextOutput(output) } for name, logger := range c.loggers { if re == nil || re.MatchString(name) { logger.getHandler().SetTextOutput(output) } } }
[ "func", "(", "c", "*", "LoggerCollection", ")", "SetTextOutput", "(", "re", "*", "regexp", ".", "Regexp", ",", "output", "TextOutput", ")", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock", "(", ")", "\n\n"...
// SetTextOutput will set the current output interface for all loggers with // names that match a provided regular expression. If the regular expression // is nil, then all loggers match. Note that not every handler is guaranteed // to support text output and a text output interface will only apply to // text-oriented and unstructured handlers.
[ "SetTextOutput", "will", "set", "the", "current", "output", "interface", "for", "all", "loggers", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", "nil", "then", "all", "loggers", "mat...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L196-L209
17,015
spacemonkeygo/spacelog
collection.go
SetLevel
func SetLevel(re *regexp.Regexp, level LogLevel) { DefaultLoggerCollection.SetLevel(re, level) }
go
func SetLevel(re *regexp.Regexp, level LogLevel) { DefaultLoggerCollection.SetLevel(re, level) }
[ "func", "SetLevel", "(", "re", "*", "regexp", ".", "Regexp", ",", "level", "LogLevel", ")", "{", "DefaultLoggerCollection", ".", "SetLevel", "(", "re", ",", "level", ")", "\n", "}" ]
// SetLevel will set the current log level for all loggers on the default // collection with names that match a provided regular expression. If the // regular expression is nil, then all loggers match.
[ "SetLevel", "will", "set", "the", "current", "log", "level", "for", "all", "loggers", "on", "the", "default", "collection", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", "nil", "t...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L244-L246
17,016
spacemonkeygo/spacelog
collection.go
SetHandler
func SetHandler(re *regexp.Regexp, handler Handler) { DefaultLoggerCollection.SetHandler(re, handler) }
go
func SetHandler(re *regexp.Regexp, handler Handler) { DefaultLoggerCollection.SetHandler(re, handler) }
[ "func", "SetHandler", "(", "re", "*", "regexp", ".", "Regexp", ",", "handler", "Handler", ")", "{", "DefaultLoggerCollection", ".", "SetHandler", "(", "re", ",", "handler", ")", "\n", "}" ]
// SetHandler will set the current log handler for all loggers on the default // collection with names that match a provided regular expression. If the // regular expression is nil, then all loggers match.
[ "SetHandler", "will", "set", "the", "current", "log", "handler", "for", "all", "loggers", "on", "the", "default", "collection", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", "nil", ...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L251-L253
17,017
spacemonkeygo/spacelog
collection.go
SetTextTemplate
func SetTextTemplate(re *regexp.Regexp, t *template.Template) { DefaultLoggerCollection.SetTextTemplate(re, t) }
go
func SetTextTemplate(re *regexp.Regexp, t *template.Template) { DefaultLoggerCollection.SetTextTemplate(re, t) }
[ "func", "SetTextTemplate", "(", "re", "*", "regexp", ".", "Regexp", ",", "t", "*", "template", ".", "Template", ")", "{", "DefaultLoggerCollection", ".", "SetTextTemplate", "(", "re", ",", "t", ")", "\n", "}" ]
// SetTextTemplate will set the current text template for all loggers on the // default collection with names that match a provided regular expression. If // the regular expression is nil, then all loggers match. Note that not every // handler is guaranteed to support text templates and a text template will // only apply to text-oriented and unstructured handlers.
[ "SetTextTemplate", "will", "set", "the", "current", "text", "template", "for", "all", "loggers", "on", "the", "default", "collection", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", ...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L260-L262
17,018
spacemonkeygo/spacelog
collection.go
SetTextOutput
func SetTextOutput(re *regexp.Regexp, output TextOutput) { DefaultLoggerCollection.SetTextOutput(re, output) }
go
func SetTextOutput(re *regexp.Regexp, output TextOutput) { DefaultLoggerCollection.SetTextOutput(re, output) }
[ "func", "SetTextOutput", "(", "re", "*", "regexp", ".", "Regexp", ",", "output", "TextOutput", ")", "{", "DefaultLoggerCollection", ".", "SetTextOutput", "(", "re", ",", "output", ")", "\n", "}" ]
// SetTextOutput will set the current output interface for all loggers on the // default collection with names that match a provided regular expression. If // the regular expression is nil, then all loggers match. Note that not every // handler is guaranteed to support text output and a text output interface // will only apply to text-oriented and unstructured handlers.
[ "SetTextOutput", "will", "set", "the", "current", "output", "interface", "for", "all", "loggers", "on", "the", "default", "collection", "with", "names", "that", "match", "a", "provided", "regular", "expression", ".", "If", "the", "regular", "expression", "is", ...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/collection.go#L269-L271
17,019
spacemonkeygo/spacelog
logger.go
Scope
func (l *Logger) Scope(name string) *Logger { return l.collection.getLogger(l.name+"."+name, l.getLevel(), l.getHandler()) }
go
func (l *Logger) Scope(name string) *Logger { return l.collection.getLogger(l.name+"."+name, l.getLevel(), l.getHandler()) }
[ "func", "(", "l", "*", "Logger", ")", "Scope", "(", "name", "string", ")", "*", "Logger", "{", "return", "l", ".", "collection", ".", "getLogger", "(", "l", ".", "name", "+", "\"", "\"", "+", "name", ",", "l", ".", "getLevel", "(", ")", ",", "l...
// Scope returns a new Logger with the same level and handler, using the // receiver Logger's name as a prefix.
[ "Scope", "returns", "a", "new", "Logger", "with", "the", "same", "level", "and", "handler", "using", "the", "receiver", "Logger", "s", "name", "as", "a", "prefix", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/logger.go#L38-L41
17,020
spacemonkeygo/spacelog
capture_other.go
CaptureOutputToFd
func CaptureOutputToFd(fd int) error { err := syscall.Dup2(fd, syscall.Stdout) if err != nil { return err } err = syscall.Dup2(fd, syscall.Stderr) if err != nil { return err } return nil }
go
func CaptureOutputToFd(fd int) error { err := syscall.Dup2(fd, syscall.Stdout) if err != nil { return err } err = syscall.Dup2(fd, syscall.Stderr) if err != nil { return err } return nil }
[ "func", "CaptureOutputToFd", "(", "fd", "int", ")", "error", "{", "err", ":=", "syscall", ".", "Dup2", "(", "fd", ",", "syscall", ".", "Stdout", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "syscall", ".",...
// CaptureOutputToFd redirects the current process' stdout and stderr file // descriptors to the given file descriptor, using the dup2 syscall.
[ "CaptureOutputToFd", "redirects", "the", "current", "process", "stdout", "and", "stderr", "file", "descriptors", "to", "the", "given", "file", "descriptor", "using", "the", "dup2", "syscall", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/capture_other.go#L28-L38
17,021
spacemonkeygo/spacelog
output.go
NewBufferedOutput
func NewBufferedOutput(output TextOutput, buffer int) *BufferedOutput { if buffer < 0 { buffer = 0 } b := &BufferedOutput{ o: output, c: make(chan bufferMsg, buffer)} go b.process() return b }
go
func NewBufferedOutput(output TextOutput, buffer int) *BufferedOutput { if buffer < 0 { buffer = 0 } b := &BufferedOutput{ o: output, c: make(chan bufferMsg, buffer)} go b.process() return b }
[ "func", "NewBufferedOutput", "(", "output", "TextOutput", ",", "buffer", "int", ")", "*", "BufferedOutput", "{", "if", "buffer", "<", "0", "{", "buffer", "=", "0", "\n", "}", "\n", "b", ":=", "&", "BufferedOutput", "{", "o", ":", "output", ",", "c", ...
// NewBufferedOutput returns a BufferedOutput wrapping output with a buffer // size of buffer.
[ "NewBufferedOutput", "returns", "a", "BufferedOutput", "wrapping", "output", "with", "a", "buffer", "size", "of", "buffer", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/output.go#L70-L79
17,022
spacemonkeygo/spacelog
output.go
Close
func (b *BufferedOutput) Close() { b.close_once.Do(func() { close(b.c) }) b.running.Lock() b.running.Unlock() }
go
func (b *BufferedOutput) Close() { b.close_once.Do(func() { close(b.c) }) b.running.Lock() b.running.Unlock() }
[ "func", "(", "b", "*", "BufferedOutput", ")", "Close", "(", ")", "{", "b", ".", "close_once", ".", "Do", "(", "func", "(", ")", "{", "close", "(", "b", ".", "c", ")", "\n", "}", ")", "\n", "b", ".", "running", ".", "Lock", "(", ")", "\n", "...
// Close shuts down the BufferedOutput's processing
[ "Close", "shuts", "down", "the", "BufferedOutput", "s", "processing" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/output.go#L82-L88
17,023
spacemonkeygo/spacelog
output.go
NewFileWriterOutput
func NewFileWriterOutput(path string) (*FileWriterOutput, error) { fo := &FileWriterOutput{path: path} fh, err := fo.openFile() if err != nil { return nil, err } fo.WriterOutput = NewWriterOutput(fh) return fo, nil }
go
func NewFileWriterOutput(path string) (*FileWriterOutput, error) { fo := &FileWriterOutput{path: path} fh, err := fo.openFile() if err != nil { return nil, err } fo.WriterOutput = NewWriterOutput(fh) return fo, nil }
[ "func", "NewFileWriterOutput", "(", "path", "string", ")", "(", "*", "FileWriterOutput", ",", "error", ")", "{", "fo", ":=", "&", "FileWriterOutput", "{", "path", ":", "path", "}", "\n", "fh", ",", "err", ":=", "fo", ".", "openFile", "(", ")", "\n", ...
// Creates a new FileWriterOutput object. This is the only case where an // error opening the file will be reported to the caller; if we try to // reopen it later and the reopen fails, we'll just keep trying until it // works.
[ "Creates", "a", "new", "FileWriterOutput", "object", ".", "This", "is", "the", "only", "case", "where", "an", "error", "opening", "the", "file", "will", "be", "reported", "to", "the", "caller", ";", "if", "we", "try", "to", "reopen", "it", "later", "and"...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/output.go#L125-L133
17,024
spacemonkeygo/spacelog
output.go
openFile
func (fo *FileWriterOutput) openFile() (*os.File, error) { return os.OpenFile(fo.path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) }
go
func (fo *FileWriterOutput) openFile() (*os.File, error) { return os.OpenFile(fo.path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) }
[ "func", "(", "fo", "*", "FileWriterOutput", ")", "openFile", "(", ")", "(", "*", "os", ".", "File", ",", "error", ")", "{", "return", "os", ".", "OpenFile", "(", "fo", ".", "path", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", "|", "os"...
// Try to open the file with the path associated with this object.
[ "Try", "to", "open", "the", "file", "with", "the", "path", "associated", "with", "this", "object", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/output.go#L136-L138
17,025
spacemonkeygo/spacelog
output.go
Output
func (fo *FileWriterOutput) Output(ll LogLevel, message []byte) { if fo.WriterOutput == nil { fh, err := fo.openFile() if err != nil { fo.fallbackLog("Could not open %#v: %s", fo.path, err) return } fo.WriterOutput = NewWriterOutput(fh) } fo.WriterOutput.Output(ll, message) }
go
func (fo *FileWriterOutput) Output(ll LogLevel, message []byte) { if fo.WriterOutput == nil { fh, err := fo.openFile() if err != nil { fo.fallbackLog("Could not open %#v: %s", fo.path, err) return } fo.WriterOutput = NewWriterOutput(fh) } fo.WriterOutput.Output(ll, message) }
[ "func", "(", "fo", "*", "FileWriterOutput", ")", "Output", "(", "ll", "LogLevel", ",", "message", "[", "]", "byte", ")", "{", "if", "fo", ".", "WriterOutput", "==", "nil", "{", "fh", ",", "err", ":=", "fo", ".", "openFile", "(", ")", "\n", "if", ...
// Output a log line by writing it to the file. If the file has been // released, try to open it again. If that fails, cry for a little // while, then throw away the message and carry on.
[ "Output", "a", "log", "line", "by", "writing", "it", "to", "the", "file", ".", "If", "the", "file", "has", "been", "released", "try", "to", "open", "it", "again", ".", "If", "that", "fails", "cry", "for", "a", "little", "while", "then", "throw", "awa...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/output.go#L151-L161
17,026
spacemonkeygo/spacelog
syslog.go
NewSyslogOutput
func NewSyslogOutput(facility SyslogPriority, tag string) ( TextOutput, error) { w, err := syslog.New(syslog.Priority(facility), tag) if err != nil { return nil, err } return &SyslogOutput{w: w}, nil }
go
func NewSyslogOutput(facility SyslogPriority, tag string) ( TextOutput, error) { w, err := syslog.New(syslog.Priority(facility), tag) if err != nil { return nil, err } return &SyslogOutput{w: w}, nil }
[ "func", "NewSyslogOutput", "(", "facility", "SyslogPriority", ",", "tag", "string", ")", "(", "TextOutput", ",", "error", ")", "{", "w", ",", "err", ":=", "syslog", ".", "New", "(", "syslog", ".", "Priority", "(", "facility", ")", ",", "tag", ")", "\n"...
// NewSyslogOutput returns a TextOutput object that writes to syslog using // the given facility and tag. The log level will be determined by the log // event.
[ "NewSyslogOutput", "returns", "a", "TextOutput", "object", "that", "writes", "to", "syslog", "using", "the", "given", "facility", "and", "tag", ".", "The", "log", "level", "will", "be", "determined", "by", "the", "log", "event", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/syslog.go#L34-L41
17,027
andygrunwald/go-trending
trending.go
NewTrendingWithClient
func NewTrendingWithClient(client *http.Client) *Trending { baseURL, _ := url.Parse(defaultBaseURL) t := Trending{ BaseURL: baseURL, Client: client, } return &t }
go
func NewTrendingWithClient(client *http.Client) *Trending { baseURL, _ := url.Parse(defaultBaseURL) t := Trending{ BaseURL: baseURL, Client: client, } return &t }
[ "func", "NewTrendingWithClient", "(", "client", "*", "http", ".", "Client", ")", "*", "Trending", "{", "baseURL", ",", "_", ":=", "url", ".", "Parse", "(", "defaultBaseURL", ")", "\n", "t", ":=", "Trending", "{", "BaseURL", ":", "baseURL", ",", "Client",...
// NewTrendingWithClient allows providing a custom http.Client to use for fetching trending items. // It allows setting timeouts or using 3rd party http.Client implementations, such as Google App Engine // urlfetch.Client.
[ "NewTrendingWithClient", "allows", "providing", "a", "custom", "http", ".", "Client", "to", "use", "for", "fetching", "trending", "items", ".", "It", "allows", "setting", "timeouts", "or", "using", "3rd", "party", "http", ".", "Client", "implementations", "such"...
5a4d422f8977c920038cdd9523a0c5e711053387
https://github.com/andygrunwald/go-trending/blob/5a4d422f8977c920038cdd9523a0c5e711053387/trending.go#L148-L155
17,028
andygrunwald/go-trending
trending.go
generateLanguages
func (t *Trending) generateLanguages(mainSelector string) ([]Language, error) { var languages []Language // Generate the URL to call u, err := t.generateURL(modeLanguages, "", "") if err != nil { return languages, err } // Get document res, err := t.Client.Get(u.String()) if err != nil { return languages, err } doc, err := goquery.NewDocumentFromResponse(res) if err != nil { return languages, err } // Query our information doc.Find(mainSelector).Each(func(i int, s *goquery.Selection) { languageAddress, _ := s.Attr("href") languageURLName := "" filterURL, _ := url.Parse(languageAddress) re := regexp.MustCompile("github.com/trending/([^/\\?]*)") if matches := re.FindStringSubmatch(languageAddress); len(matches) >= 2 && len(matches[1]) > 0 { languageURLName = matches[1] } language := Language{ Name: strings.TrimSpace(s.Text()), URLName: languageURLName, URL: filterURL, } languages = append(languages, language) }) return languages, nil }
go
func (t *Trending) generateLanguages(mainSelector string) ([]Language, error) { var languages []Language // Generate the URL to call u, err := t.generateURL(modeLanguages, "", "") if err != nil { return languages, err } // Get document res, err := t.Client.Get(u.String()) if err != nil { return languages, err } doc, err := goquery.NewDocumentFromResponse(res) if err != nil { return languages, err } // Query our information doc.Find(mainSelector).Each(func(i int, s *goquery.Selection) { languageAddress, _ := s.Attr("href") languageURLName := "" filterURL, _ := url.Parse(languageAddress) re := regexp.MustCompile("github.com/trending/([^/\\?]*)") if matches := re.FindStringSubmatch(languageAddress); len(matches) >= 2 && len(matches[1]) > 0 { languageURLName = matches[1] } language := Language{ Name: strings.TrimSpace(s.Text()), URLName: languageURLName, URL: filterURL, } languages = append(languages, language) }) return languages, nil }
[ "func", "(", "t", "*", "Trending", ")", "generateLanguages", "(", "mainSelector", "string", ")", "(", "[", "]", "Language", ",", "error", ")", "{", "var", "languages", "[", "]", "Language", "\n\n", "// Generate the URL to call", "u", ",", "err", ":=", "t",...
// generateLanguages will retrieve the languages out of the github document. // Trending languages are shown on the right side as a small list. // Other languages are hidden in a dropdown at this site
[ "generateLanguages", "will", "retrieve", "the", "languages", "out", "of", "the", "github", "document", ".", "Trending", "languages", "are", "shown", "on", "the", "right", "side", "as", "a", "small", "list", ".", "Other", "languages", "are", "hidden", "in", "...
5a4d422f8977c920038cdd9523a0c5e711053387
https://github.com/andygrunwald/go-trending/blob/5a4d422f8977c920038cdd9523a0c5e711053387/trending.go#L268-L309
17,029
andygrunwald/go-trending
trending.go
newDeveloper
func (t *Trending) newDeveloper(name, fullName string, linkURL, avatarURL *url.URL) Developer { return Developer{ ID: t.getUserIDBasedOnAvatarURL(avatarURL), DisplayName: name, FullName: fullName, URL: linkURL, Avatar: avatarURL, } }
go
func (t *Trending) newDeveloper(name, fullName string, linkURL, avatarURL *url.URL) Developer { return Developer{ ID: t.getUserIDBasedOnAvatarURL(avatarURL), DisplayName: name, FullName: fullName, URL: linkURL, Avatar: avatarURL, } }
[ "func", "(", "t", "*", "Trending", ")", "newDeveloper", "(", "name", ",", "fullName", "string", ",", "linkURL", ",", "avatarURL", "*", "url", ".", "URL", ")", "Developer", "{", "return", "Developer", "{", "ID", ":", "t", ".", "getUserIDBasedOnAvatarURL", ...
// newDeveloper is a utility function to create a new Developer
[ "newDeveloper", "is", "a", "utility", "function", "to", "create", "a", "new", "Developer" ]
5a4d422f8977c920038cdd9523a0c5e711053387
https://github.com/andygrunwald/go-trending/blob/5a4d422f8977c920038cdd9523a0c5e711053387/trending.go#L363-L371
17,030
andygrunwald/go-trending
trending.go
buildAvatarURL
func (t *Trending) buildAvatarURL(avatar string, exists bool) *url.URL { if exists == false { return nil } avatarURL, err := url.Parse(avatar) if err != nil { return nil } // Remove s parameter // The "s" parameter controls the size of the avatar q := avatarURL.Query() q.Del("s") avatarURL.RawQuery = q.Encode() return avatarURL }
go
func (t *Trending) buildAvatarURL(avatar string, exists bool) *url.URL { if exists == false { return nil } avatarURL, err := url.Parse(avatar) if err != nil { return nil } // Remove s parameter // The "s" parameter controls the size of the avatar q := avatarURL.Query() q.Del("s") avatarURL.RawQuery = q.Encode() return avatarURL }
[ "func", "(", "t", "*", "Trending", ")", "buildAvatarURL", "(", "avatar", "string", ",", "exists", "bool", ")", "*", "url", ".", "URL", "{", "if", "exists", "==", "false", "{", "return", "nil", "\n", "}", "\n\n", "avatarURL", ",", "err", ":=", "url", ...
// buildAvatarURL will build a url.URL out of the Avatar URL provided by Github
[ "buildAvatarURL", "will", "build", "a", "url", ".", "URL", "out", "of", "the", "Avatar", "URL", "provided", "by", "Github" ]
5a4d422f8977c920038cdd9523a0c5e711053387
https://github.com/andygrunwald/go-trending/blob/5a4d422f8977c920038cdd9523a0c5e711053387/trending.go#L382-L399
17,031
andygrunwald/go-trending
trending.go
getUserIDBasedOnAvatarURL
func (t *Trending) getUserIDBasedOnAvatarURL(avatarURL *url.URL) int { id := 0 if avatarURL == nil { return id } re := regexp.MustCompile("u/([0-9]+)") if matches := re.FindStringSubmatch(avatarURL.Path); len(matches) >= 2 && len(matches[1]) > 0 { id, _ = strconv.Atoi(matches[1]) } return id }
go
func (t *Trending) getUserIDBasedOnAvatarURL(avatarURL *url.URL) int { id := 0 if avatarURL == nil { return id } re := regexp.MustCompile("u/([0-9]+)") if matches := re.FindStringSubmatch(avatarURL.Path); len(matches) >= 2 && len(matches[1]) > 0 { id, _ = strconv.Atoi(matches[1]) } return id }
[ "func", "(", "t", "*", "Trending", ")", "getUserIDBasedOnAvatarURL", "(", "avatarURL", "*", "url", ".", "URL", ")", "int", "{", "id", ":=", "0", "\n", "if", "avatarURL", "==", "nil", "{", "return", "id", "\n", "}", "\n\n", "re", ":=", "regexp", ".", ...
// getUserIDBasedOnAvatarLink determines the UserID based on an avatar link avatarURL
[ "getUserIDBasedOnAvatarLink", "determines", "the", "UserID", "based", "on", "an", "avatar", "link", "avatarURL" ]
5a4d422f8977c920038cdd9523a0c5e711053387
https://github.com/andygrunwald/go-trending/blob/5a4d422f8977c920038cdd9523a0c5e711053387/trending.go#L402-L413
17,032
andygrunwald/go-trending
trending.go
generateURL
func (t *Trending) generateURL(mode, time, language string) (*url.URL, error) { urlStr := urlTrendingPath if mode == modeDevelopers { urlStr += urlDevelopersPath } u := t.appendBaseHostToPath(urlStr, true) q := u.Query() if len(time) > 0 { q.Set("since", time) } if len(language) > 0 { q.Set("l", language) } u.RawQuery = q.Encode() return u, nil }
go
func (t *Trending) generateURL(mode, time, language string) (*url.URL, error) { urlStr := urlTrendingPath if mode == modeDevelopers { urlStr += urlDevelopersPath } u := t.appendBaseHostToPath(urlStr, true) q := u.Query() if len(time) > 0 { q.Set("since", time) } if len(language) > 0 { q.Set("l", language) } u.RawQuery = q.Encode() return u, nil }
[ "func", "(", "t", "*", "Trending", ")", "generateURL", "(", "mode", ",", "time", ",", "language", "string", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "urlStr", ":=", "urlTrendingPath", "\n", "if", "mode", "==", "modeDevelopers", "{", ...
// generateURL will generate the correct URL to call the github site. // // Depending on mode, time and language it will set the correct pathes and query parameters.
[ "generateURL", "will", "generate", "the", "correct", "URL", "to", "call", "the", "github", "site", ".", "Depending", "on", "mode", "time", "and", "language", "it", "will", "set", "the", "correct", "pathes", "and", "query", "parameters", "." ]
5a4d422f8977c920038cdd9523a0c5e711053387
https://github.com/andygrunwald/go-trending/blob/5a4d422f8977c920038cdd9523a0c5e711053387/trending.go#L446-L465
17,033
libp2p/go-flow-metrics
registry.go
ForEach
func (r *MeterRegistry) ForEach(iterFunc func(string, *Meter)) { r.meters.Range(func(k, v interface{}) bool { iterFunc(k.(string), v.(*Meter)) return true }) }
go
func (r *MeterRegistry) ForEach(iterFunc func(string, *Meter)) { r.meters.Range(func(k, v interface{}) bool { iterFunc(k.(string), v.(*Meter)) return true }) }
[ "func", "(", "r", "*", "MeterRegistry", ")", "ForEach", "(", "iterFunc", "func", "(", "string", ",", "*", "Meter", ")", ")", "{", "r", ".", "meters", ".", "Range", "(", "func", "(", "k", ",", "v", "interface", "{", "}", ")", "bool", "{", "iterFun...
// ForEach calls the passed function for each registered meter.
[ "ForEach", "calls", "the", "passed", "function", "for", "each", "registered", "meter", "." ]
b1aae8c25b4822de58289e6af21362f93753fa23
https://github.com/libp2p/go-flow-metrics/blob/b1aae8c25b4822de58289e6af21362f93753fa23/registry.go#L30-L35
17,034
libp2p/go-flow-metrics
meter.go
Mark
func (m *Meter) Mark(count uint64) { if count > 0 && atomic.AddUint64(&m.accumulator, count) == count { // I'm the first one to bump this above 0. // Register it. globalSweeper.Register(m) } }
go
func (m *Meter) Mark(count uint64) { if count > 0 && atomic.AddUint64(&m.accumulator, count) == count { // I'm the first one to bump this above 0. // Register it. globalSweeper.Register(m) } }
[ "func", "(", "m", "*", "Meter", ")", "Mark", "(", "count", "uint64", ")", "{", "if", "count", ">", "0", "&&", "atomic", ".", "AddUint64", "(", "&", "m", ".", "accumulator", ",", "count", ")", "==", "count", "{", "// I'm the first one to bump this above 0...
// Mark updates the total.
[ "Mark", "updates", "the", "total", "." ]
b1aae8c25b4822de58289e6af21362f93753fa23
https://github.com/libp2p/go-flow-metrics/blob/b1aae8c25b4822de58289e6af21362f93753fa23/meter.go#L27-L33
17,035
libp2p/go-flow-metrics
meter.go
Snapshot
func (m *Meter) Snapshot() Snapshot { globalSweeper.mutex.RLock() defer globalSweeper.mutex.RUnlock() return m.snapshot }
go
func (m *Meter) Snapshot() Snapshot { globalSweeper.mutex.RLock() defer globalSweeper.mutex.RUnlock() return m.snapshot }
[ "func", "(", "m", "*", "Meter", ")", "Snapshot", "(", ")", "Snapshot", "{", "globalSweeper", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "globalSweeper", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "m", ".", "snapshot", "\n", "}"...
// Snapshot gets a consistent snapshot of the total and rate.
[ "Snapshot", "gets", "a", "consistent", "snapshot", "of", "the", "total", "and", "rate", "." ]
b1aae8c25b4822de58289e6af21362f93753fa23
https://github.com/libp2p/go-flow-metrics/blob/b1aae8c25b4822de58289e6af21362f93753fa23/meter.go#L36-L40
17,036
kevinburke/rest
client.go
NewClient
func NewClient(user, pass, base string) *Client { return &Client{ ID: user, Token: pass, Client: defaultHttpClient, Base: base, UploadType: JSON, ErrorParser: DefaultErrorParser, } }
go
func NewClient(user, pass, base string) *Client { return &Client{ ID: user, Token: pass, Client: defaultHttpClient, Base: base, UploadType: JSON, ErrorParser: DefaultErrorParser, } }
[ "func", "NewClient", "(", "user", ",", "pass", ",", "base", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "ID", ":", "user", ",", "Token", ":", "pass", ",", "Client", ":", "defaultHttpClient", ",", "Base", ":", "base", ",", "Upload...
// NewClient returns a new Client with the given user and password. Base is the // scheme+domain to hit for all requests.
[ "NewClient", "returns", "a", "new", "Client", "with", "the", "given", "user", "and", "password", ".", "Base", "is", "the", "scheme", "+", "domain", "to", "hit", "for", "all", "requests", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/client.go#L57-L66
17,037
kevinburke/rest
client.go
NewBearerClient
func NewBearerClient(token, base string) *Client { return &Client{ ID: "", Token: token, Client: defaultHttpClient, Base: base, UploadType: JSON, ErrorParser: DefaultErrorParser, useBearerAuth: true, } }
go
func NewBearerClient(token, base string) *Client { return &Client{ ID: "", Token: token, Client: defaultHttpClient, Base: base, UploadType: JSON, ErrorParser: DefaultErrorParser, useBearerAuth: true, } }
[ "func", "NewBearerClient", "(", "token", ",", "base", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "ID", ":", "\"", "\"", ",", "Token", ":", "token", ",", "Client", ":", "defaultHttpClient", ",", "Base", ":", "base", ",", "UploadTyp...
// NewBearerClient returns a new Client configured to use Bearer authentication.
[ "NewBearerClient", "returns", "a", "new", "Client", "configured", "to", "use", "Bearer", "authentication", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/client.go#L69-L79
17,038
kevinburke/rest
client.go
DialSocket
func (c *Client) DialSocket(socket string, transport *http.Transport) { dialSock := func(ctx context.Context, proto, addr string) (conn net.Conn, err error) { return defaultDialer.DialContext(ctx, "unix", socket) } if transport == nil { ht := http.DefaultTransport.(*http.Transport) transport = &http.Transport{ Proxy: ht.Proxy, MaxIdleConns: ht.MaxIdleConns, IdleConnTimeout: ht.IdleConnTimeout, TLSHandshakeTimeout: ht.TLSHandshakeTimeout, ExpectContinueTimeout: ht.ExpectContinueTimeout, DialContext: dialSock, } } if c.Client == nil { // need to copy this so we don't modify the default client c.Client = &http.Client{ Timeout: defaultHttpClient.Timeout, } } switch tp := c.Client.Transport.(type) { case nil, *Transport: c.Client.Transport = &Transport{ RoundTripper: transport, Debug: DefaultTransport.Debug, Output: DefaultTransport.Output, } case *http.Transport: tp = transport default: panic(fmt.Sprintf("could not set DialSocket on unknown transport: %#v", tp)) } }
go
func (c *Client) DialSocket(socket string, transport *http.Transport) { dialSock := func(ctx context.Context, proto, addr string) (conn net.Conn, err error) { return defaultDialer.DialContext(ctx, "unix", socket) } if transport == nil { ht := http.DefaultTransport.(*http.Transport) transport = &http.Transport{ Proxy: ht.Proxy, MaxIdleConns: ht.MaxIdleConns, IdleConnTimeout: ht.IdleConnTimeout, TLSHandshakeTimeout: ht.TLSHandshakeTimeout, ExpectContinueTimeout: ht.ExpectContinueTimeout, DialContext: dialSock, } } if c.Client == nil { // need to copy this so we don't modify the default client c.Client = &http.Client{ Timeout: defaultHttpClient.Timeout, } } switch tp := c.Client.Transport.(type) { case nil, *Transport: c.Client.Transport = &Transport{ RoundTripper: transport, Debug: DefaultTransport.Debug, Output: DefaultTransport.Output, } case *http.Transport: tp = transport default: panic(fmt.Sprintf("could not set DialSocket on unknown transport: %#v", tp)) } }
[ "func", "(", "c", "*", "Client", ")", "DialSocket", "(", "socket", "string", ",", "transport", "*", "http", ".", "Transport", ")", "{", "dialSock", ":=", "func", "(", "ctx", "context", ".", "Context", ",", "proto", ",", "addr", "string", ")", "(", "c...
// DialSocket configures c to use the provided socket and http.Transport to // dial a Unix socket instead of a TCP port. // // If transport is nil, the settings from DefaultTransport are used.
[ "DialSocket", "configures", "c", "to", "use", "the", "provided", "socket", "and", "http", ".", "Transport", "to", "dial", "a", "Unix", "socket", "instead", "of", "a", "TCP", "port", ".", "If", "transport", "is", "nil", "the", "settings", "from", "DefaultTr...
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/client.go#L91-L124
17,039
kevinburke/rest
client.go
NewRequest
func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error) { req, err := http.NewRequest(method, c.Base+path, body) if err != nil { return nil, err } switch { case c.useBearerAuth && c.Token != "": req.Header.Add("Authorization", "Bearer "+c.Token) case !c.useBearerAuth && (c.ID != "" || c.Token != ""): req.SetBasicAuth(c.ID, c.Token) } req.Header.Add("User-Agent", ua) req.Header.Add("Accept", "application/json") req.Header.Add("Accept-Charset", "utf-8") if method == "POST" || method == "PUT" { uploadType := c.UploadType if uploadType == "" { uploadType = JSON } req.Header.Add("Content-Type", fmt.Sprintf("%s; charset=utf-8", uploadType)) } return req, nil }
go
func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error) { req, err := http.NewRequest(method, c.Base+path, body) if err != nil { return nil, err } switch { case c.useBearerAuth && c.Token != "": req.Header.Add("Authorization", "Bearer "+c.Token) case !c.useBearerAuth && (c.ID != "" || c.Token != ""): req.SetBasicAuth(c.ID, c.Token) } req.Header.Add("User-Agent", ua) req.Header.Add("Accept", "application/json") req.Header.Add("Accept-Charset", "utf-8") if method == "POST" || method == "PUT" { uploadType := c.UploadType if uploadType == "" { uploadType = JSON } req.Header.Add("Content-Type", fmt.Sprintf("%s; charset=utf-8", uploadType)) } return req, nil }
[ "func", "(", "c", "*", "Client", ")", "NewRequest", "(", "method", ",", "path", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "m...
// NewRequest creates a new Request and sets basic auth based on the client's // authentication information.
[ "NewRequest", "creates", "a", "new", "Request", "and", "sets", "basic", "auth", "based", "on", "the", "client", "s", "authentication", "information", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/client.go#L128-L150
17,040
kevinburke/rest
client.go
Do
func (c *Client) Do(r *http.Request, v interface{}) error { var res *http.Response var err error if c.Client == nil { res, err = defaultHttpClient.Do(r) } else { res, err = c.Client.Do(r) } if err != nil { return err } defer res.Body.Close() if res.StatusCode >= 400 { if c.ErrorParser != nil { return c.ErrorParser(res) } return DefaultErrorParser(res) } resBody, err := ioutil.ReadAll(res.Body) if err != nil { return err } if v == nil || res.StatusCode == http.StatusNoContent { return nil } else { return json.Unmarshal(resBody, v) } }
go
func (c *Client) Do(r *http.Request, v interface{}) error { var res *http.Response var err error if c.Client == nil { res, err = defaultHttpClient.Do(r) } else { res, err = c.Client.Do(r) } if err != nil { return err } defer res.Body.Close() if res.StatusCode >= 400 { if c.ErrorParser != nil { return c.ErrorParser(res) } return DefaultErrorParser(res) } resBody, err := ioutil.ReadAll(res.Body) if err != nil { return err } if v == nil || res.StatusCode == http.StatusNoContent { return nil } else { return json.Unmarshal(resBody, v) } }
[ "func", "(", "c", "*", "Client", ")", "Do", "(", "r", "*", "http", ".", "Request", ",", "v", "interface", "{", "}", ")", "error", "{", "var", "res", "*", "http", ".", "Response", "\n", "var", "err", "error", "\n", "if", "c", ".", "Client", "=="...
// Do performs the HTTP request. If the HTTP response is in the 2xx range, // Unmarshal the response body into v. If the response status code is 400 or // above, attempt to Unmarshal the response into an Error. Otherwise return // a generic http error.
[ "Do", "performs", "the", "HTTP", "request", ".", "If", "the", "HTTP", "response", "is", "in", "the", "2xx", "range", "Unmarshal", "the", "response", "body", "into", "v", ".", "If", "the", "response", "status", "code", "is", "400", "or", "above", "attempt...
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/client.go#L156-L184
17,041
kevinburke/rest
client.go
DefaultErrorParser
func DefaultErrorParser(resp *http.Response) error { resBody, err := ioutil.ReadAll(resp.Body) if err != nil { return err } defer resp.Body.Close() rerr := new(Error) err = json.Unmarshal(resBody, rerr) if err != nil { return fmt.Errorf("invalid response body: %s", string(resBody)) } if rerr.Title == "" { return fmt.Errorf("invalid response body: %s", string(resBody)) } else { rerr.Status = resp.StatusCode return rerr } }
go
func DefaultErrorParser(resp *http.Response) error { resBody, err := ioutil.ReadAll(resp.Body) if err != nil { return err } defer resp.Body.Close() rerr := new(Error) err = json.Unmarshal(resBody, rerr) if err != nil { return fmt.Errorf("invalid response body: %s", string(resBody)) } if rerr.Title == "" { return fmt.Errorf("invalid response body: %s", string(resBody)) } else { rerr.Status = resp.StatusCode return rerr } }
[ "func", "DefaultErrorParser", "(", "resp", "*", "http", ".", "Response", ")", "error", "{", "resBody", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", ...
// DefaultErrorParser attempts to parse the response body as a rest.Error. If // it cannot do so, return an error containing the entire response body.
[ "DefaultErrorParser", "attempts", "to", "parse", "the", "response", "body", "as", "a", "rest", ".", "Error", ".", "If", "it", "cannot", "do", "so", "return", "an", "error", "containing", "the", "entire", "response", "body", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/client.go#L188-L205
17,042
kevinburke/rest
rest.go
ServerError
func ServerError(w http.ResponseWriter, r *http.Request, err error) { handlerMu.RLock() f, ok := handlerMap[http.StatusInternalServerError] handlerMu.RUnlock() if ok { r = ctxSetErr(r, err) f.ServeHTTP(w, r) } else { defaultServerError(w, r, err) } }
go
func ServerError(w http.ResponseWriter, r *http.Request, err error) { handlerMu.RLock() f, ok := handlerMap[http.StatusInternalServerError] handlerMu.RUnlock() if ok { r = ctxSetErr(r, err) f.ServeHTTP(w, r) } else { defaultServerError(w, r, err) } }
[ "func", "ServerError", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "err", "error", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusInternalServer...
// ServerError logs the error to the Logger, and then responds to the request // with a generic 500 server error message. ServerError panics if err is nil.
[ "ServerError", "logs", "the", "error", "to", "the", "Logger", "and", "then", "responds", "to", "the", "request", "with", "a", "generic", "500", "server", "error", "message", ".", "ServerError", "panics", "if", "err", "is", "nil", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L77-L87
17,043
kevinburke/rest
rest.go
NotFound
func NotFound(w http.ResponseWriter, r *http.Request) { handlerMu.RLock() f, ok := handlerMap[http.StatusNotFound] handlerMu.RUnlock() if ok { f.ServeHTTP(w, r) } else { defaultNotFound(w, r) } }
go
func NotFound(w http.ResponseWriter, r *http.Request) { handlerMu.RLock() f, ok := handlerMap[http.StatusNotFound] handlerMu.RUnlock() if ok { f.ServeHTTP(w, r) } else { defaultNotFound(w, r) } }
[ "func", "NotFound", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusNotFound", "]", "\n", "handlerMu", "...
// NotFound returns a 404 Not Found error to the client.
[ "NotFound", "returns", "a", "404", "Not", "Found", "error", "to", "the", "client", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L114-L123
17,044
kevinburke/rest
rest.go
BadRequest
func BadRequest(w http.ResponseWriter, r *http.Request, err *Error) { handlerMu.RLock() f, ok := handlerMap[http.StatusBadRequest] handlerMu.RUnlock() if ok { r = ctxSetErr(r, err) f.ServeHTTP(w, r) } else { defaultBadRequest(w, r, err) } }
go
func BadRequest(w http.ResponseWriter, r *http.Request, err *Error) { handlerMu.RLock() f, ok := handlerMap[http.StatusBadRequest] handlerMu.RUnlock() if ok { r = ctxSetErr(r, err) f.ServeHTTP(w, r) } else { defaultBadRequest(w, r, err) } }
[ "func", "BadRequest", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "err", "*", "Error", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusBadReque...
// BadRequest logs a 400 error and then returns a 400 response to the client.
[ "BadRequest", "logs", "a", "400", "error", "and", "then", "returns", "a", "400", "response", "to", "the", "client", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L136-L146
17,045
kevinburke/rest
rest.go
Gone
func Gone(w http.ResponseWriter, r *http.Request) { handlerMu.RLock() f, ok := handlerMap[http.StatusGone] handlerMu.RUnlock() if ok { f.ServeHTTP(w, r) } else { defaultGone(w, r) } }
go
func Gone(w http.ResponseWriter, r *http.Request) { handlerMu.RLock() f, ok := handlerMap[http.StatusGone] handlerMu.RUnlock() if ok { f.ServeHTTP(w, r) } else { defaultGone(w, r) } }
[ "func", "Gone", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusGone", "]", "\n", "handlerMu", ".", "R...
// Gone responds to the request with a 410 Gone error message
[ "Gone", "responds", "to", "the", "request", "with", "a", "410", "Gone", "error", "message" ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L155-L164
17,046
kevinburke/rest
rest.go
NotAllowed
func NotAllowed(w http.ResponseWriter, r *http.Request) { handlerMu.RLock() f, ok := handlerMap[http.StatusMethodNotAllowed] handlerMu.RUnlock() if ok { f.ServeHTTP(w, r) } else { defaultNotAllowed(w, r) } }
go
func NotAllowed(w http.ResponseWriter, r *http.Request) { handlerMu.RLock() f, ok := handlerMap[http.StatusMethodNotAllowed] handlerMu.RUnlock() if ok { f.ServeHTTP(w, r) } else { defaultNotAllowed(w, r) } }
[ "func", "NotAllowed", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusMethodNotAllowed", "]", "\n", "handl...
// NotAllowed returns a generic HTTP 405 Not Allowed status and response body // to the client.
[ "NotAllowed", "returns", "a", "generic", "HTTP", "405", "Not", "Allowed", "status", "and", "response", "body", "to", "the", "client", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L205-L214
17,047
kevinburke/rest
rest.go
Forbidden
func Forbidden(w http.ResponseWriter, r *http.Request, err *Error) { handlerMu.RLock() f, ok := handlerMap[http.StatusForbidden] handlerMu.RUnlock() if ok { r = ctxSetErr(r, err) f.ServeHTTP(w, r) } else { defaultForbidden(w, r, err) } }
go
func Forbidden(w http.ResponseWriter, r *http.Request, err *Error) { handlerMu.RLock() f, ok := handlerMap[http.StatusForbidden] handlerMu.RUnlock() if ok { r = ctxSetErr(r, err) f.ServeHTTP(w, r) } else { defaultForbidden(w, r, err) } }
[ "func", "Forbidden", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "err", "*", "Error", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusForbidden...
// Forbidden returns a 403 Forbidden status code to the client, with the given // Error object in the response body.
[ "Forbidden", "returns", "a", "403", "Forbidden", "status", "code", "to", "the", "client", "with", "the", "given", "Error", "object", "in", "the", "response", "body", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L228-L238
17,048
kevinburke/rest
rest.go
NoContent
func NoContent(w http.ResponseWriter) { // No custom handler since there's no custom behavior. w.Header().Del("Content-Type") w.WriteHeader(http.StatusNoContent) }
go
func NoContent(w http.ResponseWriter) { // No custom handler since there's no custom behavior. w.Header().Del("Content-Type") w.WriteHeader(http.StatusNoContent) }
[ "func", "NoContent", "(", "w", "http", ".", "ResponseWriter", ")", "{", "// No custom handler since there's no custom behavior.", "w", ".", "Header", "(", ")", ".", "Del", "(", "\"", "\"", ")", "\n", "w", ".", "WriteHeader", "(", "http", ".", "StatusNoContent"...
// NoContent returns a 204 No Content message.
[ "NoContent", "returns", "a", "204", "No", "Content", "message", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L252-L256
17,049
kevinburke/rest
rest.go
Unauthorized
func Unauthorized(w http.ResponseWriter, r *http.Request, domain string) { handlerMu.RLock() f, ok := handlerMap[http.StatusUnauthorized] handlerMu.RUnlock() if ok { r = ctxSetDomain(r, domain) f.ServeHTTP(w, r) } else { defaultUnauthorized(w, r, domain) } }
go
func Unauthorized(w http.ResponseWriter, r *http.Request, domain string) { handlerMu.RLock() f, ok := handlerMap[http.StatusUnauthorized] handlerMu.RUnlock() if ok { r = ctxSetDomain(r, domain) f.ServeHTTP(w, r) } else { defaultUnauthorized(w, r, domain) } }
[ "func", "Unauthorized", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "domain", "string", ")", "{", "handlerMu", ".", "RLock", "(", ")", "\n", "f", ",", "ok", ":=", "handlerMap", "[", "http", ".", "StatusUnauthori...
// Unauthorized sets the Domain in the request context
[ "Unauthorized", "sets", "the", "Domain", "in", "the", "request", "context" ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/rest.go#L259-L269
17,050
kevinburke/rest
ctx.go
CtxErr
func CtxErr(r *http.Request) error { val := r.Context().Value(errCtx) if val == nil { return nil } return val.(error) }
go
func CtxErr(r *http.Request) error { val := r.Context().Value(errCtx) if val == nil { return nil } return val.(error) }
[ "func", "CtxErr", "(", "r", "*", "http", ".", "Request", ")", "error", "{", "val", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "errCtx", ")", "\n", "if", "val", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "val", "....
// CtxErr returns an error that's been stored in the Request context.
[ "CtxErr", "returns", "an", "error", "that", "s", "been", "stored", "in", "the", "Request", "context", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/ctx.go#L16-L22
17,051
kevinburke/rest
ctx.go
CtxDomain
func CtxDomain(r *http.Request) string { val := r.Context().Value(domainCtx) if val == nil { return "" } return val.(string) }
go
func CtxDomain(r *http.Request) string { val := r.Context().Value(domainCtx) if val == nil { return "" } return val.(string) }
[ "func", "CtxDomain", "(", "r", "*", "http", ".", "Request", ")", "string", "{", "val", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "domainCtx", ")", "\n", "if", "val", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return",...
// CtxDomain returns a domain that's been set on the request. Use it to get the // domain set on a 401 error handler.
[ "CtxDomain", "returns", "a", "domain", "that", "s", "been", "set", "on", "the", "request", ".", "Use", "it", "to", "get", "the", "domain", "set", "on", "a", "401", "error", "handler", "." ]
77c0c82d0ded0190f0dfece37d24b76e17b4bb73
https://github.com/kevinburke/rest/blob/77c0c82d0ded0190f0dfece37d24b76e17b4bb73/ctx.go#L31-L37
17,052
jfreymuth/vorbis
vorbis.go
IsHeader
func IsHeader(packet []byte) bool { return len(packet) > 6 && packet[0]&1 == 1 && packet[1] == 'v' && packet[2] == 'o' && packet[3] == 'r' && packet[4] == 'b' && packet[5] == 'i' && packet[6] == 's' }
go
func IsHeader(packet []byte) bool { return len(packet) > 6 && packet[0]&1 == 1 && packet[1] == 'v' && packet[2] == 'o' && packet[3] == 'r' && packet[4] == 'b' && packet[5] == 'i' && packet[6] == 's' }
[ "func", "IsHeader", "(", "packet", "[", "]", "byte", ")", "bool", "{", "return", "len", "(", "packet", ")", ">", "6", "&&", "packet", "[", "0", "]", "&", "1", "==", "1", "&&", "packet", "[", "1", "]", "==", "'v'", "&&", "packet", "[", "2", "]...
// IsHeader returns wether the packet is a vorbis header.
[ "IsHeader", "returns", "wether", "the", "packet", "is", "a", "vorbis", "header", "." ]
2f16367d086d143e8e946cc5ee24618147d673dc
https://github.com/jfreymuth/vorbis/blob/2f16367d086d143e8e946cc5ee24618147d673dc/vorbis.go#L62-L70
17,053
motemen/go-quickfix
quickfix.go
removeFromStmtList
func removeFromStmtList(node ast.Node, list []ast.Stmt) bool { for i, s := range list { if s == node { for ; i < len(list)-1; i++ { list[i] = list[i+1] } list[len(list)-1] = &ast.EmptyStmt{} return true } } return false }
go
func removeFromStmtList(node ast.Node, list []ast.Stmt) bool { for i, s := range list { if s == node { for ; i < len(list)-1; i++ { list[i] = list[i+1] } list[len(list)-1] = &ast.EmptyStmt{} return true } } return false }
[ "func", "removeFromStmtList", "(", "node", "ast", ".", "Node", ",", "list", "[", "]", "ast", ".", "Stmt", ")", "bool", "{", "for", "i", ",", "s", ":=", "range", "list", "{", "if", "s", "==", "node", "{", "for", ";", "i", "<", "len", "(", "list"...
// removeFromStmtList remove node from slice of statements list. This function // modifies list in-place and pads rest of the slice with ast.EmptyStmt.
[ "removeFromStmtList", "remove", "node", "from", "slice", "of", "statements", "list", ".", "This", "function", "modifies", "list", "in", "-", "place", "and", "pads", "rest", "of", "the", "slice", "with", "ast", ".", "EmptyStmt", "." ]
5c522febc6796f9c2ceabf9374a75490e2d268da
https://github.com/motemen/go-quickfix/blob/5c522febc6796f9c2ceabf9374a75490e2d268da/quickfix.go#L379-L391
17,054
apcera/logray
logger.go
New
func New() *Logger { defaultOutputMutex.RLock() defer defaultOutputMutex.RUnlock() logger := &Logger{ Fields: make(map[string]interface{}), outputs: make([]*loggerOutputWrapper, len(defaultOutputs)), } copy(logger.outputs, defaultOutputs) return logger }
go
func New() *Logger { defaultOutputMutex.RLock() defer defaultOutputMutex.RUnlock() logger := &Logger{ Fields: make(map[string]interface{}), outputs: make([]*loggerOutputWrapper, len(defaultOutputs)), } copy(logger.outputs, defaultOutputs) return logger }
[ "func", "New", "(", ")", "*", "Logger", "{", "defaultOutputMutex", ".", "RLock", "(", ")", "\n", "defer", "defaultOutputMutex", ".", "RUnlock", "(", ")", "\n\n", "logger", ":=", "&", "Logger", "{", "Fields", ":", "make", "(", "map", "[", "string", "]",...
// New returns a new Logger with the default configuration.
[ "New", "returns", "a", "new", "Logger", "with", "the", "default", "configuration", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L48-L59
17,055
apcera/logray
logger.go
AddDefaultOutput
func AddDefaultOutput(uri string, classes ...LogClass) error { // generate it lo, err := createOutputWrapper(uri, classes) if err != nil { return err } if lo == nil { return nil } // Lock the default outputs defaultOutputMutex.Lock() defer defaultOutputMutex.Unlock() defaultOutputs = append(defaultOutputs, lo) return nil }
go
func AddDefaultOutput(uri string, classes ...LogClass) error { // generate it lo, err := createOutputWrapper(uri, classes) if err != nil { return err } if lo == nil { return nil } // Lock the default outputs defaultOutputMutex.Lock() defer defaultOutputMutex.Unlock() defaultOutputs = append(defaultOutputs, lo) return nil }
[ "func", "AddDefaultOutput", "(", "uri", "string", ",", "classes", "...", "LogClass", ")", "error", "{", "// generate it", "lo", ",", "err", ":=", "createOutputWrapper", "(", "uri", ",", "classes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ...
// AddDefaultOutput adds a new default output which will be used on newly // created Loggers.
[ "AddDefaultOutput", "adds", "a", "new", "default", "output", "which", "will", "be", "used", "on", "newly", "created", "Loggers", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L63-L78
17,056
apcera/logray
logger.go
ResetDefaultLogLevel
func ResetDefaultLogLevel(classes ...LogClass) { // Combine the output classes into just one class := NONE for _, c := range classes { class |= c } defaultOutputMutex.Lock() for _, o := range defaultOutputs { o.Class = class } defaultOutputMutex.Unlock() }
go
func ResetDefaultLogLevel(classes ...LogClass) { // Combine the output classes into just one class := NONE for _, c := range classes { class |= c } defaultOutputMutex.Lock() for _, o := range defaultOutputs { o.Class = class } defaultOutputMutex.Unlock() }
[ "func", "ResetDefaultLogLevel", "(", "classes", "...", "LogClass", ")", "{", "// Combine the output classes into just one", "class", ":=", "NONE", "\n", "for", "_", ",", "c", ":=", "range", "classes", "{", "class", "|=", "c", "\n", "}", "\n\n", "defaultOutputMut...
// ResetDefaultLogLevel can be used to reconfigure the existing default outputs // all be at a new log level.
[ "ResetDefaultLogLevel", "can", "be", "used", "to", "reconfigure", "the", "existing", "default", "outputs", "all", "be", "at", "a", "new", "log", "level", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L98-L110
17,057
apcera/logray
logger.go
Clone
func (logger *Logger) Clone() *Logger { clone := &Logger{} // copy the outputs logger.outputMutex.RLock() clone.outputs = make([]*loggerOutputWrapper, len(logger.outputs)) copy(clone.outputs, logger.outputs) logger.outputMutex.RUnlock() // copy the fields clone.Fields = make(map[string]interface{}, len(logger.Fields)) for k, v := range logger.Fields { clone.Fields[k] = v } return clone }
go
func (logger *Logger) Clone() *Logger { clone := &Logger{} // copy the outputs logger.outputMutex.RLock() clone.outputs = make([]*loggerOutputWrapper, len(logger.outputs)) copy(clone.outputs, logger.outputs) logger.outputMutex.RUnlock() // copy the fields clone.Fields = make(map[string]interface{}, len(logger.Fields)) for k, v := range logger.Fields { clone.Fields[k] = v } return clone }
[ "func", "(", "logger", "*", "Logger", ")", "Clone", "(", ")", "*", "Logger", "{", "clone", ":=", "&", "Logger", "{", "}", "\n\n", "// copy the outputs", "logger", ".", "outputMutex", ".", "RLock", "(", ")", "\n", "clone", ".", "outputs", "=", "make", ...
// Clone returns a new Logger object and copies over the configuration and all // fields along with it.
[ "Clone", "returns", "a", "new", "Logger", "object", "and", "copies", "over", "the", "configuration", "and", "all", "fields", "along", "with", "it", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L114-L129
17,058
apcera/logray
logger.go
AddOutput
func (logger *Logger) AddOutput(uri string, classes ...LogClass) error { // generate it lo, err := createOutputWrapper(uri, classes) if err != nil { return err } if lo == nil { return nil } // Lock our outputs logger.outputMutex.Lock() defer logger.outputMutex.Unlock() logger.outputs = append(logger.outputs, lo) return nil }
go
func (logger *Logger) AddOutput(uri string, classes ...LogClass) error { // generate it lo, err := createOutputWrapper(uri, classes) if err != nil { return err } if lo == nil { return nil } // Lock our outputs logger.outputMutex.Lock() defer logger.outputMutex.Unlock() logger.outputs = append(logger.outputs, lo) return nil }
[ "func", "(", "logger", "*", "Logger", ")", "AddOutput", "(", "uri", "string", ",", "classes", "...", "LogClass", ")", "error", "{", "// generate it", "lo", ",", "err", ":=", "createOutputWrapper", "(", "uri", ",", "classes", ")", "\n", "if", "err", "!=",...
// AddOutput adds a new output for the Logger based on the provided URI.
[ "AddOutput", "adds", "a", "new", "output", "for", "the", "Logger", "based", "on", "the", "provided", "URI", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L132-L147
17,059
apcera/logray
logger.go
UpdateOutput
func (logger *Logger) UpdateOutput(uri string, classes ...LogClass) error { u, err := url.Parse(uri) if err != nil { return err } class := NONE for _, c := range classes { class |= c } newoutputs := make([]*loggerOutputWrapper, 0) // Lock our outputs logger.outputMutex.Lock() defer logger.outputMutex.Unlock() for i, o := range logger.outputs { if (o.Class == class || o.Class&class != 0) && u.Scheme == o.OutputWrapper.URL.Scheme { // Found a match // generate it with new uri for intersection of given classes and output's classes. lo, err := createOutputWrapperForClass(uri, o.Class&class) if err != nil { return err } if lo == nil { continue } logger.outputs[i] = lo // Save this output for rest of the classes not being updated. // Add these later outside the loop so that these are not updated. restClasses := (o.Class ^ class) & o.Class if restClasses != NONE && restClasses != isPLUSDEF { o.Class = restClasses newoutputs = append(newoutputs, o) } } } logger.outputs = append(logger.outputs, newoutputs...) return nil }
go
func (logger *Logger) UpdateOutput(uri string, classes ...LogClass) error { u, err := url.Parse(uri) if err != nil { return err } class := NONE for _, c := range classes { class |= c } newoutputs := make([]*loggerOutputWrapper, 0) // Lock our outputs logger.outputMutex.Lock() defer logger.outputMutex.Unlock() for i, o := range logger.outputs { if (o.Class == class || o.Class&class != 0) && u.Scheme == o.OutputWrapper.URL.Scheme { // Found a match // generate it with new uri for intersection of given classes and output's classes. lo, err := createOutputWrapperForClass(uri, o.Class&class) if err != nil { return err } if lo == nil { continue } logger.outputs[i] = lo // Save this output for rest of the classes not being updated. // Add these later outside the loop so that these are not updated. restClasses := (o.Class ^ class) & o.Class if restClasses != NONE && restClasses != isPLUSDEF { o.Class = restClasses newoutputs = append(newoutputs, o) } } } logger.outputs = append(logger.outputs, newoutputs...) return nil }
[ "func", "(", "logger", "*", "Logger", ")", "UpdateOutput", "(", "uri", "string", ",", "classes", "...", "LogClass", ")", "error", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err"...
// UpdateOutput updates an existing output matching for an URI scheme // and exact classes match. For ex. if classes passed here are, DEBUG // and ERROR, it will update Outputs with Class equals to DEBUG|ERROR.
[ "UpdateOutput", "updates", "an", "existing", "output", "matching", "for", "an", "URI", "scheme", "and", "exact", "classes", "match", ".", "For", "ex", ".", "if", "classes", "passed", "here", "are", "DEBUG", "and", "ERROR", "it", "will", "update", "Outputs", ...
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L152-L196
17,060
apcera/logray
logger.go
ResetOutput
func (logger *Logger) ResetOutput() { logger.outputMutex.Lock() logger.outputs = make([]*loggerOutputWrapper, 0) logger.outputMutex.Unlock() }
go
func (logger *Logger) ResetOutput() { logger.outputMutex.Lock() logger.outputs = make([]*loggerOutputWrapper, 0) logger.outputMutex.Unlock() }
[ "func", "(", "logger", "*", "Logger", ")", "ResetOutput", "(", ")", "{", "logger", ".", "outputMutex", ".", "Lock", "(", ")", "\n", "logger", ".", "outputs", "=", "make", "(", "[", "]", "*", "loggerOutputWrapper", ",", "0", ")", "\n", "logger", ".", ...
// ResetOutput clears all the previously defined outputs on the Logger.
[ "ResetOutput", "clears", "all", "the", "previously", "defined", "outputs", "on", "the", "Logger", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L199-L203
17,061
apcera/logray
logger.go
createOutputWrapper
func createOutputWrapper(uri string, classes []LogClass) (*loggerOutputWrapper, error) { // If the caller didn't give us any classes to configure then we do // nothing. This can be either an error or not, and since it is just as easy // either way we define this as being a no op rather than error condition. if len(classes) == 0 { return nil, nil } // Combine the output classes into just one class := NONE for _, c := range classes { class |= c } return createOutputWrapperForClass(uri, class) }
go
func createOutputWrapper(uri string, classes []LogClass) (*loggerOutputWrapper, error) { // If the caller didn't give us any classes to configure then we do // nothing. This can be either an error or not, and since it is just as easy // either way we define this as being a no op rather than error condition. if len(classes) == 0 { return nil, nil } // Combine the output classes into just one class := NONE for _, c := range classes { class |= c } return createOutputWrapperForClass(uri, class) }
[ "func", "createOutputWrapper", "(", "uri", "string", ",", "classes", "[", "]", "LogClass", ")", "(", "*", "loggerOutputWrapper", ",", "error", ")", "{", "// If the caller didn't give us any classes to configure then we do", "// nothing. This can be either an error or not, and s...
// createOutputWrapper generates a new loggerOutputWrapper based on the passed // parameters. It will return an error if it fails to generate the output. It // will return nil, nil if there are no classes specified.
[ "createOutputWrapper", "generates", "a", "new", "loggerOutputWrapper", "based", "on", "the", "passed", "parameters", ".", "It", "will", "return", "an", "error", "if", "it", "fails", "to", "generate", "the", "output", ".", "It", "will", "return", "nil", "nil", ...
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L208-L223
17,062
apcera/logray
logger.go
createOutputWrapperForClass
func createOutputWrapperForClass(uri string, class LogClass) (*loggerOutputWrapper, error) { // Generate the output wrapper or capture the cached one ow, err := newOutput(uri) if err != nil { return nil, err } // generate the wrapper lo := &loggerOutputWrapper{Class: class, OutputWrapper: ow} return lo, nil }
go
func createOutputWrapperForClass(uri string, class LogClass) (*loggerOutputWrapper, error) { // Generate the output wrapper or capture the cached one ow, err := newOutput(uri) if err != nil { return nil, err } // generate the wrapper lo := &loggerOutputWrapper{Class: class, OutputWrapper: ow} return lo, nil }
[ "func", "createOutputWrapperForClass", "(", "uri", "string", ",", "class", "LogClass", ")", "(", "*", "loggerOutputWrapper", ",", "error", ")", "{", "// Generate the output wrapper or capture the cached one", "ow", ",", "err", ":=", "newOutput", "(", "uri", ")", "\n...
// createOutputWrapperForClass generates a new loggerOutputWrapper based on the passed // parameters. It will return an error if it fails to generate the output.
[ "createOutputWrapperForClass", "generates", "a", "new", "loggerOutputWrapper", "based", "on", "the", "passed", "parameters", ".", "It", "will", "return", "an", "error", "if", "it", "fails", "to", "generate", "the", "output", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L227-L237
17,063
apcera/logray
logger.go
RemoveFields
func (logger *Logger) RemoveFields(keys ...string) { for _, s := range keys { delete(logger.Fields, s) } }
go
func (logger *Logger) RemoveFields(keys ...string) { for _, s := range keys { delete(logger.Fields, s) } }
[ "func", "(", "logger", "*", "Logger", ")", "RemoveFields", "(", "keys", "...", "string", ")", "{", "for", "_", ",", "s", ":=", "range", "keys", "{", "delete", "(", "logger", ".", "Fields", ",", "s", ")", "\n", "}", "\n", "}" ]
// RemoveFields will remove any of the mentioned keys from the Logger's Fields.
[ "RemoveFields", "will", "remove", "any", "of", "the", "mentioned", "keys", "from", "the", "Logger", "s", "Fields", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L245-L249
17,064
apcera/logray
logger.go
SetFields
func (logger *Logger) SetFields(fields map[string]interface{}) { for k, v := range fields { logger.Fields[k] = v } }
go
func (logger *Logger) SetFields(fields map[string]interface{}) { for k, v := range fields { logger.Fields[k] = v } }
[ "func", "(", "logger", "*", "Logger", ")", "SetFields", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "for", "k", ",", "v", ":=", "range", "fields", "{", "logger", ".", "Fields", "[", "k", "]", "=", "v", "\n", "}", ...
// SetFields can be used to copy all of the values in the provided fields map to // the current Logger.
[ "SetFields", "can", "be", "used", "to", "copy", "all", "of", "the", "values", "in", "the", "provided", "fields", "map", "to", "the", "current", "Logger", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L253-L257
17,065
apcera/logray
logger.go
SetField
func (logger *Logger) SetField(key string, value interface{}) { logger.Fields[key] = value }
go
func (logger *Logger) SetField(key string, value interface{}) { logger.Fields[key] = value }
[ "func", "(", "logger", "*", "Logger", ")", "SetField", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "logger", ".", "Fields", "[", "key", "]", "=", "value", "\n", "}" ]
// SetField is used to set the specified field to the provided value on the // current Logger.
[ "SetField", "is", "used", "to", "set", "the", "specified", "field", "to", "the", "provided", "value", "on", "the", "current", "Logger", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L261-L263
17,066
apcera/logray
logger.go
log
func (logger *Logger) log(logClass LogClass, message string) { ld := logger.newLineData(logClass, message) b := &backgroundLineLogger{ lineData: *ld, logger: logger, } transitChannel <- b }
go
func (logger *Logger) log(logClass LogClass, message string) { ld := logger.newLineData(logClass, message) b := &backgroundLineLogger{ lineData: *ld, logger: logger, } transitChannel <- b }
[ "func", "(", "logger", "*", "Logger", ")", "log", "(", "logClass", "LogClass", ",", "message", "string", ")", "{", "ld", ":=", "logger", ".", "newLineData", "(", "logClass", ",", "message", ")", "\n", "b", ":=", "&", "backgroundLineLogger", "{", "lineDat...
// log is the internal function which creates the line data for the message and // pushes it onto the transit channel.
[ "log", "is", "the", "internal", "function", "which", "creates", "the", "line", "data", "for", "the", "message", "and", "pushes", "it", "onto", "the", "transit", "channel", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L342-L349
17,067
apcera/logray
logger.go
Flush
func (logger *Logger) Flush() { b := &backgroundFlusher{ logger: logger, updateChan: make(chan struct{}), } transitChannel <- b <-b.updateChan }
go
func (logger *Logger) Flush() { b := &backgroundFlusher{ logger: logger, updateChan: make(chan struct{}), } transitChannel <- b <-b.updateChan }
[ "func", "(", "logger", "*", "Logger", ")", "Flush", "(", ")", "{", "b", ":=", "&", "backgroundFlusher", "{", "logger", ":", "logger", ",", "updateChan", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "transitChannel", "<-", "b", ...
// Flush is used to ensure the logger has flushed all queued log lines to its // outputs before returning.
[ "Flush", "is", "used", "to", "ensure", "the", "logger", "has", "flushed", "all", "queued", "log", "lines", "to", "its", "outputs", "before", "returning", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L353-L360
17,068
apcera/logray
logger.go
newLineData
func (logger *Logger) newLineData(logClass LogClass, message string) *LineData { ld := &LineData{ Message: message, Class: logClass, TimeStamp: time.Now(), } ld.Fields = make(map[string]interface{}, len(logger.Fields)) for k, v := range logger.Fields { ld.Fields[k] = v } packageFilenameLine(ld, 4) if logClass == ERROR { ld.Fields["stack"] = gatherStack() } return ld }
go
func (logger *Logger) newLineData(logClass LogClass, message string) *LineData { ld := &LineData{ Message: message, Class: logClass, TimeStamp: time.Now(), } ld.Fields = make(map[string]interface{}, len(logger.Fields)) for k, v := range logger.Fields { ld.Fields[k] = v } packageFilenameLine(ld, 4) if logClass == ERROR { ld.Fields["stack"] = gatherStack() } return ld }
[ "func", "(", "logger", "*", "Logger", ")", "newLineData", "(", "logClass", "LogClass", ",", "message", "string", ")", "*", "LineData", "{", "ld", ":=", "&", "LineData", "{", "Message", ":", "message", ",", "Class", ":", "logClass", ",", "TimeStamp", ":",...
// newLineData creates the struct that wraps a log message and will capture the // source of the logging message from the stack.
[ "newLineData", "creates", "the", "struct", "that", "wraps", "a", "log", "message", "and", "will", "capture", "the", "source", "of", "the", "logging", "message", "from", "the", "stack", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logger.go#L364-L381
17,069
apcera/logray
logclass.go
String
func (l LogClass) String() string { switch l { case NONE: return "none" case TRACE: return "trace" case TRACEPLUS: return "trace+" case DEBUG: return "debug" case DEBUGPLUS: return "debug+" case INFO: return "info" case INFOPLUS: return "info+" case WARN: return "warn" case WARNPLUS: return "warn+" case ERROR: return "error" case ERRORPLUS: return "error+" case FATAL: return "fatal" case FATALPLUS: return "fatal+" case ALL: return "all" } // The consts do not match the class, so iterate over the base types and // generate a combination of the log classes. classes := make([]string, 0) for _, lc := range baseLogClasses { if l&lc == lc { classes = append(classes, lc.String()) } } return strings.Join(classes, "|") }
go
func (l LogClass) String() string { switch l { case NONE: return "none" case TRACE: return "trace" case TRACEPLUS: return "trace+" case DEBUG: return "debug" case DEBUGPLUS: return "debug+" case INFO: return "info" case INFOPLUS: return "info+" case WARN: return "warn" case WARNPLUS: return "warn+" case ERROR: return "error" case ERRORPLUS: return "error+" case FATAL: return "fatal" case FATALPLUS: return "fatal+" case ALL: return "all" } // The consts do not match the class, so iterate over the base types and // generate a combination of the log classes. classes := make([]string, 0) for _, lc := range baseLogClasses { if l&lc == lc { classes = append(classes, lc.String()) } } return strings.Join(classes, "|") }
[ "func", "(", "l", "LogClass", ")", "String", "(", ")", "string", "{", "switch", "l", "{", "case", "NONE", ":", "return", "\"", "\"", "\n", "case", "TRACE", ":", "return", "\"", "\"", "\n", "case", "TRACEPLUS", ":", "return", "\"", "\"", "\n", "case...
// Returns string representation of the given class.
[ "Returns", "string", "representation", "of", "the", "given", "class", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logclass.go#L14-L55
17,070
apcera/logray
logclass.go
ParseLogClass
func ParseLogClass(s string) (LogClass, error) { switch strings.ToLower(s) { case "none": return NONE, nil case "trace": return TRACE, nil case "trace+": return TRACEPLUS, nil case "debug": return DEBUG, nil case "debug+": return DEBUGPLUS, nil case "info": return INFO, nil case "info+": return INFOPLUS, nil case "warn": return WARN, nil case "warn+": return WARNPLUS, nil case "error": return ERROR, nil case "error+": return ERRORPLUS, nil case "fatal": return FATAL, nil case "fatal+": return FATALPLUS, nil case "all": return ALL, nil } return NONE, fmt.Errorf("Invalid LogClass string.") }
go
func ParseLogClass(s string) (LogClass, error) { switch strings.ToLower(s) { case "none": return NONE, nil case "trace": return TRACE, nil case "trace+": return TRACEPLUS, nil case "debug": return DEBUG, nil case "debug+": return DEBUGPLUS, nil case "info": return INFO, nil case "info+": return INFOPLUS, nil case "warn": return WARN, nil case "warn+": return WARNPLUS, nil case "error": return ERROR, nil case "error+": return ERRORPLUS, nil case "fatal": return FATAL, nil case "fatal+": return FATALPLUS, nil case "all": return ALL, nil } return NONE, fmt.Errorf("Invalid LogClass string.") }
[ "func", "ParseLogClass", "(", "s", "string", ")", "(", "LogClass", ",", "error", ")", "{", "switch", "strings", ".", "ToLower", "(", "s", ")", "{", "case", "\"", "\"", ":", "return", "NONE", ",", "nil", "\n", "case", "\"", "\"", ":", "return", "TRA...
// Parses a logclass string into a LogClass object. This call is case // insensitive. If the string is not recognised then an error will be returned // and LogClass will be set to NONE.
[ "Parses", "a", "logclass", "string", "into", "a", "LogClass", "object", ".", "This", "call", "is", "case", "insensitive", ".", "If", "the", "string", "is", "not", "recognised", "then", "an", "error", "will", "be", "returned", "and", "LogClass", "will", "be...
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/logclass.go#L60-L92
17,071
apcera/logray
util.go
packageFilenameLine
func packageFilenameLine(ld *LineData, depth int) { i, filename, linenum, ok := runtime.Caller(depth) if !ok { return } // Strip the directory from the filename. Even on Windows this is slash // delimited. See https://github.com/golang/go/issues/3335. fileParts := strings.Split(filename, "/") ld.SourceFile = fileParts[len(fileParts)-1] ld.SourceLine = linenum // Set up params from the call stack. f := runtime.FuncForPC(i) if f == nil { return } // generate the separate package name and function name packagePath := strings.Split(f.Name(), "/") n := len(packagePath) pkgFunc := strings.SplitN(packagePath[n-1], ".", 2) if len(pkgFunc) != 2 { return } pkg := strings.Join(packagePath[:n-1], "/") + fmt.Sprintf("/%s", pkgFunc[0]) ld.CallingPackage = pkg ld.CallingFunction = pkgFunc[1] }
go
func packageFilenameLine(ld *LineData, depth int) { i, filename, linenum, ok := runtime.Caller(depth) if !ok { return } // Strip the directory from the filename. Even on Windows this is slash // delimited. See https://github.com/golang/go/issues/3335. fileParts := strings.Split(filename, "/") ld.SourceFile = fileParts[len(fileParts)-1] ld.SourceLine = linenum // Set up params from the call stack. f := runtime.FuncForPC(i) if f == nil { return } // generate the separate package name and function name packagePath := strings.Split(f.Name(), "/") n := len(packagePath) pkgFunc := strings.SplitN(packagePath[n-1], ".", 2) if len(pkgFunc) != 2 { return } pkg := strings.Join(packagePath[:n-1], "/") + fmt.Sprintf("/%s", pkgFunc[0]) ld.CallingPackage = pkg ld.CallingFunction = pkgFunc[1] }
[ "func", "packageFilenameLine", "(", "ld", "*", "LineData", ",", "depth", "int", ")", "{", "i", ",", "filename", ",", "linenum", ",", "ok", ":=", "runtime", ".", "Caller", "(", "depth", ")", "\n", "if", "!", "ok", "{", "return", "\n", "}", "\n\n", "...
// packageFilenameLine updates the LineData to include the package, function, // source file, and line number.
[ "packageFilenameLine", "updates", "the", "LineData", "to", "include", "the", "package", "function", "source", "file", "and", "line", "number", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/util.go#L13-L42
17,072
apcera/logray
util.go
gatherStack
func gatherStack() string { root := runtime.GOROOT() stack := make([]string, 0, 10) pc := make([]uintptr, 10) depth := runtime.Callers(4, pc) for i := 0; i < depth; i++ { f := runtime.FuncForPC(pc[i]) file, line := f.FileLine(pc[i]) if strings.HasPrefix(file, root) { continue } path := strings.Split(f.Name(), "/") pl := len(path) fun := path[pl-1] fa := strings.Split(fun, ".") if fa[0] == "server" && pl >= 2 { fa[0] = path[pl-2] } w := strings.Join(fa, ".") stack = append(stack, fmt.Sprintf("\t%s:%d %s", file, line, w)) } return "\n" + strings.Join(stack, "\n") }
go
func gatherStack() string { root := runtime.GOROOT() stack := make([]string, 0, 10) pc := make([]uintptr, 10) depth := runtime.Callers(4, pc) for i := 0; i < depth; i++ { f := runtime.FuncForPC(pc[i]) file, line := f.FileLine(pc[i]) if strings.HasPrefix(file, root) { continue } path := strings.Split(f.Name(), "/") pl := len(path) fun := path[pl-1] fa := strings.Split(fun, ".") if fa[0] == "server" && pl >= 2 { fa[0] = path[pl-2] } w := strings.Join(fa, ".") stack = append(stack, fmt.Sprintf("\t%s:%d %s", file, line, w)) } return "\n" + strings.Join(stack, "\n") }
[ "func", "gatherStack", "(", ")", "string", "{", "root", ":=", "runtime", ".", "GOROOT", "(", ")", "\n", "stack", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "10", ")", "\n", "pc", ":=", "make", "(", "[", "]", "uintptr", ",", "10", ")"...
// gatherStack generates a stack trace to attach to error messages.
[ "gatherStack", "generates", "a", "stack", "trace", "to", "attach", "to", "error", "messages", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/util.go#L45-L68
17,073
apcera/logray
output.go
AddNewOutputFunc
func AddNewOutputFunc(name string, f NewOutputFunc) bool { updateMutex.Lock() defer updateMutex.Unlock() return lockedAddNewOutputFunc(name, f) }
go
func AddNewOutputFunc(name string, f NewOutputFunc) bool { updateMutex.Lock() defer updateMutex.Unlock() return lockedAddNewOutputFunc(name, f) }
[ "func", "AddNewOutputFunc", "(", "name", "string", ",", "f", "NewOutputFunc", ")", "bool", "{", "updateMutex", ".", "Lock", "(", ")", "\n", "defer", "updateMutex", ".", "Unlock", "(", ")", "\n", "return", "lockedAddNewOutputFunc", "(", "name", ",", "f", ")...
// Adds a new output type to the map of possible outputs. This defines the // Scheme that will be provided via the URL. Fragments are managed by the Output // system rather than being dealt with in this function.
[ "Adds", "a", "new", "output", "type", "to", "the", "map", "of", "possible", "outputs", ".", "This", "defines", "the", "Scheme", "that", "will", "be", "provided", "via", "the", "URL", ".", "Fragments", "are", "managed", "by", "the", "Output", "system", "r...
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/output.go#L72-L76
17,074
apcera/logray
output.go
lockedSetupOutputMap
func lockedSetupOutputMap() { newOutputFuncMap = make(map[string]NewOutputFunc, 100) newOutputFuncMap["stdout"] = newOutputFuncStdout newOutputFuncMap["stderr"] = newOutputFuncStderr newOutputFuncMap["file"] = newOutputFuncFile newOutputFuncMap["fd"] = newOutputFuncFd newOutputFuncMap["discard"] = newOutputFuncDiscard outputMap = make(map[string]*outputWrapper, 100) }
go
func lockedSetupOutputMap() { newOutputFuncMap = make(map[string]NewOutputFunc, 100) newOutputFuncMap["stdout"] = newOutputFuncStdout newOutputFuncMap["stderr"] = newOutputFuncStderr newOutputFuncMap["file"] = newOutputFuncFile newOutputFuncMap["fd"] = newOutputFuncFd newOutputFuncMap["discard"] = newOutputFuncDiscard outputMap = make(map[string]*outputWrapper, 100) }
[ "func", "lockedSetupOutputMap", "(", ")", "{", "newOutputFuncMap", "=", "make", "(", "map", "[", "string", "]", "NewOutputFunc", ",", "100", ")", "\n", "newOutputFuncMap", "[", "\"", "\"", "]", "=", "newOutputFuncStdout", "\n", "newOutputFuncMap", "[", "\"", ...
// Sets up the outputMap with all known URL Scheme parsers.
[ "Sets", "up", "the", "outputMap", "with", "all", "known", "URL", "Scheme", "parsers", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/output.go#L79-L87
17,075
apcera/logray
output.go
newOutput
func newOutput(uri string) (o *outputWrapper, err error) { updateMutex.Lock() defer updateMutex.Unlock() return lockedNewOutput(uri) }
go
func newOutput(uri string) (o *outputWrapper, err error) { updateMutex.Lock() defer updateMutex.Unlock() return lockedNewOutput(uri) }
[ "func", "newOutput", "(", "uri", "string", ")", "(", "o", "*", "outputWrapper", ",", "err", "error", ")", "{", "updateMutex", ".", "Lock", "(", ")", "\n", "defer", "updateMutex", ".", "Unlock", "(", ")", "\n", "return", "lockedNewOutput", "(", "uri", "...
// Creates a new Output destination and configures it as default as // possible.
[ "Creates", "a", "new", "Output", "destination", "and", "configures", "it", "as", "default", "as", "possible", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/output.go#L100-L104
17,076
apcera/logray
iooutput.go
Write
func (o *ioOutput) Write(ld *LineData) error { size := o.initialSize + len(ld.Message) + 1 buffer := bytes.NewBuffer(make([]byte, 0, size)) // Walk the formatting functions calling them so they can write to the output // buffer where possible. for _, f := range o.formatFuncs { if err := f(ld, buffer); err != nil { return err } } // Return the bytes that we generated in the functions above. data := buffer.Bytes() if len(data) == 0 || data[len(data)-1] != '\n' { if err := buffer.WriteByte('\n'); err != nil { return err } } // Write the data in the buffer to the output writer. if _, err := o.writer.Write(buffer.Bytes()); err != nil { return err } return nil }
go
func (o *ioOutput) Write(ld *LineData) error { size := o.initialSize + len(ld.Message) + 1 buffer := bytes.NewBuffer(make([]byte, 0, size)) // Walk the formatting functions calling them so they can write to the output // buffer where possible. for _, f := range o.formatFuncs { if err := f(ld, buffer); err != nil { return err } } // Return the bytes that we generated in the functions above. data := buffer.Bytes() if len(data) == 0 || data[len(data)-1] != '\n' { if err := buffer.WriteByte('\n'); err != nil { return err } } // Write the data in the buffer to the output writer. if _, err := o.writer.Write(buffer.Bytes()); err != nil { return err } return nil }
[ "func", "(", "o", "*", "ioOutput", ")", "Write", "(", "ld", "*", "LineData", ")", "error", "{", "size", ":=", "o", ".", "initialSize", "+", "len", "(", "ld", ".", "Message", ")", "+", "1", "\n", "buffer", ":=", "bytes", ".", "NewBuffer", "(", "ma...
// Write attempts to add a line to this output object. This may be buffered, or // unbuffered so its not safe to assume that this call will not block.
[ "Write", "attempts", "to", "add", "a", "line", "to", "this", "output", "object", ".", "This", "may", "be", "buffered", "or", "unbuffered", "so", "its", "not", "safe", "to", "assume", "that", "this", "call", "will", "not", "block", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L226-L251
17,077
apcera/logray
iooutput.go
Flush
func (o *ioOutput) Flush() error { if w, ok := o.writer.(flushWriter); ok { return w.Flush() } if w, ok := o.writer.(syncWriter); ok { return w.Sync() } return nil }
go
func (o *ioOutput) Flush() error { if w, ok := o.writer.(flushWriter); ok { return w.Flush() } if w, ok := o.writer.(syncWriter); ok { return w.Sync() } return nil }
[ "func", "(", "o", "*", "ioOutput", ")", "Flush", "(", ")", "error", "{", "if", "w", ",", "ok", ":=", "o", ".", "writer", ".", "(", "flushWriter", ")", ";", "ok", "{", "return", "w", ".", "Flush", "(", ")", "\n", "}", "\n", "if", "w", ",", "...
// Flushes all logs that have been buffered for writing to this output.
[ "Flushes", "all", "logs", "that", "have", "been", "buffered", "for", "writing", "to", "this", "output", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L254-L262
17,078
apcera/logray
iooutput.go
formatFunc
func (s staticBytes) formatFunc(ld *LineData, b *bytes.Buffer) error { _, err := b.Write([]byte(s)) return err }
go
func (s staticBytes) formatFunc(ld *LineData, b *bytes.Buffer) error { _, err := b.Write([]byte(s)) return err }
[ "func", "(", "s", "staticBytes", ")", "formatFunc", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "Write", "(", "[", "]", "byte", "(", "s", ")", ")", "\n", "return", "err"...
// Can be used in the formatFuncs array
[ "Can", "be", "used", "in", "the", "formatFuncs", "array" ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L272-L275
17,079
apcera/logray
iooutput.go
addStatic
func (fp *formatParser) addStatic(b []byte) { if b == nil { return } else if len(fp.lastStatic) == 0 { fp.lastStatic = b } else { fp.lastStatic = append(fp.lastStatic, b...) } }
go
func (fp *formatParser) addStatic(b []byte) { if b == nil { return } else if len(fp.lastStatic) == 0 { fp.lastStatic = b } else { fp.lastStatic = append(fp.lastStatic, b...) } }
[ "func", "(", "fp", "*", "formatParser", ")", "addStatic", "(", "b", "[", "]", "byte", ")", "{", "if", "b", "==", "nil", "{", "return", "\n", "}", "else", "if", "len", "(", "fp", ".", "lastStatic", ")", "==", "0", "{", "fp", ".", "lastStatic", "...
// Adds a static string to the formatFuncs implementation.
[ "Adds", "a", "static", "string", "to", "the", "formatFuncs", "implementation", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L310-L318
17,080
apcera/logray
iooutput.go
commitStatic
func (fp *formatParser) commitStatic() { if len(fp.lastStatic) == 0 { return } f := staticBytes(fp.lastStatic).formatFunc fp.formatFuncs = append(fp.formatFuncs, f) fp.initialSize += len(fp.lastStatic) fp.lastStatic = nil }
go
func (fp *formatParser) commitStatic() { if len(fp.lastStatic) == 0 { return } f := staticBytes(fp.lastStatic).formatFunc fp.formatFuncs = append(fp.formatFuncs, f) fp.initialSize += len(fp.lastStatic) fp.lastStatic = nil }
[ "func", "(", "fp", "*", "formatParser", ")", "commitStatic", "(", ")", "{", "if", "len", "(", "fp", ".", "lastStatic", ")", "==", "0", "{", "return", "\n", "}", "\n", "f", ":=", "staticBytes", "(", "fp", ".", "lastStatic", ")", ".", "formatFunc", "...
// Called when a series of static strings has ended.
[ "Called", "when", "a", "series", "of", "static", "strings", "has", "ended", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L321-L329
17,081
apcera/logray
iooutput.go
addFormatFunc
func (fp *formatParser) addFormatFunc( f func(*LineData, *bytes.Buffer) error, size int, ) { fp.commitStatic() fp.formatFuncs = append(fp.formatFuncs, f) fp.initialSize += size }
go
func (fp *formatParser) addFormatFunc( f func(*LineData, *bytes.Buffer) error, size int, ) { fp.commitStatic() fp.formatFuncs = append(fp.formatFuncs, f) fp.initialSize += size }
[ "func", "(", "fp", "*", "formatParser", ")", "addFormatFunc", "(", "f", "func", "(", "*", "LineData", ",", "*", "bytes", ".", "Buffer", ")", "error", ",", "size", "int", ",", ")", "{", "fp", ".", "commitStatic", "(", ")", "\n", "fp", ".", "formatFu...
// Adds a format function to the formatFunc list.
[ "Adds", "a", "format", "function", "to", "the", "formatFunc", "list", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L332-L338
17,082
apcera/logray
iooutput.go
freshCode
func (fp *formatParser) freshCode(i int, r rune) error { fp.start = i fp.code = (*formatParser).codeCode fp.next = (*formatParser).codeNext fp.end = (*formatParser).codeEnd return nil }
go
func (fp *formatParser) freshCode(i int, r rune) error { fp.start = i fp.code = (*formatParser).codeCode fp.next = (*formatParser).codeNext fp.end = (*formatParser).codeEnd return nil }
[ "func", "(", "fp", "*", "formatParser", ")", "freshCode", "(", "i", "int", ",", "r", "rune", ")", "error", "{", "fp", ".", "start", "=", "i", "\n", "fp", ".", "code", "=", "(", "*", "formatParser", ")", ".", "codeCode", "\n", "fp", ".", "next", ...
// Called when the parser is not currently parsing a static string and the next // character in the format string is a code '%'.
[ "Called", "when", "the", "parser", "is", "not", "currently", "parsing", "a", "static", "string", "and", "the", "next", "character", "in", "the", "format", "string", "is", "a", "code", "%", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L342-L348
17,083
apcera/logray
iooutput.go
freshNext
func (fp *formatParser) freshNext(i int, r rune) error { fp.start = i fp.code = (*formatParser).staticCode fp.next = (*formatParser).staticNext fp.end = (*formatParser).staticEnd return nil }
go
func (fp *formatParser) freshNext(i int, r rune) error { fp.start = i fp.code = (*formatParser).staticCode fp.next = (*formatParser).staticNext fp.end = (*formatParser).staticEnd return nil }
[ "func", "(", "fp", "*", "formatParser", ")", "freshNext", "(", "i", "int", ",", "r", "rune", ")", "error", "{", "fp", ".", "start", "=", "i", "\n", "fp", ".", "code", "=", "(", "*", "formatParser", ")", ".", "staticCode", "\n", "fp", ".", "next",...
// Called when the parser is not currently parsing a static string and the next // character in the format string is not a '%'.
[ "Called", "when", "the", "parser", "is", "not", "currently", "parsing", "a", "static", "string", "and", "the", "next", "character", "in", "the", "format", "string", "is", "not", "a", "%", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L352-L358
17,084
apcera/logray
iooutput.go
codeCode
func (fp *formatParser) codeCode(i int, r rune) error { fp.processCode(i) fp.start = i fp.code = (*formatParser).freshCode fp.next = (*formatParser).freshNext fp.end = (*formatParser).freshEnd return nil }
go
func (fp *formatParser) codeCode(i int, r rune) error { fp.processCode(i) fp.start = i fp.code = (*formatParser).freshCode fp.next = (*formatParser).freshNext fp.end = (*formatParser).freshEnd return nil }
[ "func", "(", "fp", "*", "formatParser", ")", "codeCode", "(", "i", "int", ",", "r", "rune", ")", "error", "{", "fp", ".", "processCode", "(", "i", ")", "\n", "fp", ".", "start", "=", "i", "\n", "fp", ".", "code", "=", "(", "*", "formatParser", ...
// Called when processing a code string and another '%' is found in the format // string.
[ "Called", "when", "processing", "a", "code", "string", "and", "another", "%", "is", "found", "in", "the", "format", "string", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L369-L376
17,085
apcera/logray
iooutput.go
staticCode
func (fp *formatParser) staticCode(i int, r rune) error { data := []byte(fp.format[fp.start:i]) fp.addStatic(data) fp.start = i fp.code = (*formatParser).codeCode fp.next = (*formatParser).codeNext fp.end = (*formatParser).codeEnd return nil }
go
func (fp *formatParser) staticCode(i int, r rune) error { data := []byte(fp.format[fp.start:i]) fp.addStatic(data) fp.start = i fp.code = (*formatParser).codeCode fp.next = (*formatParser).codeNext fp.end = (*formatParser).codeEnd return nil }
[ "func", "(", "fp", "*", "formatParser", ")", "staticCode", "(", "i", "int", ",", "r", "rune", ")", "error", "{", "data", ":=", "[", "]", "byte", "(", "fp", ".", "format", "[", "fp", ".", "start", ":", "i", "]", ")", "\n", "fp", ".", "addStatic"...
// Called when processing a static string and a code '%' is found.
[ "Called", "when", "processing", "a", "static", "string", "and", "a", "code", "%", "is", "found", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L391-L399
17,086
apcera/logray
iooutput.go
staticEnd
func (fp *formatParser) staticEnd() error { fp.addStatic([]byte(fp.format[fp.start:])) fp.commitStatic() return nil }
go
func (fp *formatParser) staticEnd() error { fp.addStatic([]byte(fp.format[fp.start:])) fp.commitStatic() return nil }
[ "func", "(", "fp", "*", "formatParser", ")", "staticEnd", "(", ")", "error", "{", "fp", ".", "addStatic", "(", "[", "]", "byte", "(", "fp", ".", "format", "[", "fp", ".", "start", ":", "]", ")", ")", "\n", "fp", ".", "commitStatic", "(", ")", "...
// Called when processing a static string and the end of the format string is // found.
[ "Called", "when", "processing", "a", "static", "string", "and", "the", "end", "of", "the", "format", "string", "is", "found", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L408-L412
17,087
apcera/logray
iooutput.go
processCode
func (fp *formatParser) processCode(index int) error { code := fp.format[fp.start+1 : index] switch { case code == "": fp.addStatic([]byte("%")) // LineData strings. case code == "class": fp.addFormatFunc(ioOutputFormatClass, 6) case code == "classfixed": fp.addFormatFunc(ioOutputFormatClassFixed, 5) case code == "message": // len(ld.Message) already gets added into the buffer. fp.addFormatFunc(ioOutputFormatMessage, 0) // Time format functions. case code == "nanosecond": fp.addFormatFunc(ioOutputFormatNanoSecond, 9) case code == "second": fp.addFormatFunc(ioOutputFormatSecond, 2) case code == "minute": fp.addFormatFunc(ioOutputFormatMinute, 2) case code == "hour": fp.addFormatFunc(ioOutputFormatHour, 2) case code == "day": fp.addFormatFunc(ioOutputFormatDay, 2) case code == "month": fp.addFormatFunc(ioOutputFormatMonth, 2) case code == "year": fp.addFormatFunc(ioOutputFormatYear, 4) case code == "epoch": fp.addFormatFunc(ioOutputFormatEpoch, 10) case code == "tzoffset": fp.addFormatFunc(ioOutputFormatTZOffset, 5) case code == "tz": fp.addFormatFunc(ioOutputFormatTZ, 4) // System level tools. case code == "hostname": fp.addFormatFunc(ioOutputFormatHostname, 4) case code == "pid": fp.addFormatFunc(ioOutputFormatPid, 0) // Calling code fields. case code == "package": fp.addFormatFunc(ioOutputFormatPackage, 0) case code == "function": fp.addFormatFunc(ioOutputFormatFunction, 0) case code == "sourcefile": fp.addFormatFunc(ioOutputFormatSourceFile, 0) case code == "sourceline": fp.addFormatFunc(ioOutputFormatSourceLine, 0) case code == "json:message": fp.addFormatFunc(ioOutputFormatJsonMessage, 0) // Field access. case strings.HasPrefix(code, "field:"): if len(code) < 7 { return fmt.Errorf("Color code left empty.") } fp.addFormatFunc(ioOutputFormatField(code[6:]), 0) // Color: case strings.HasPrefix(code, "color:"): if len(code) < 7 { return fmt.Errorf("Color code left empty.") } if err := fp.setAnsiColor(code[6:]); err != nil { return err } default: // Unknown return fmt.Errorf("Unknown format code: %s", code) } return nil }
go
func (fp *formatParser) processCode(index int) error { code := fp.format[fp.start+1 : index] switch { case code == "": fp.addStatic([]byte("%")) // LineData strings. case code == "class": fp.addFormatFunc(ioOutputFormatClass, 6) case code == "classfixed": fp.addFormatFunc(ioOutputFormatClassFixed, 5) case code == "message": // len(ld.Message) already gets added into the buffer. fp.addFormatFunc(ioOutputFormatMessage, 0) // Time format functions. case code == "nanosecond": fp.addFormatFunc(ioOutputFormatNanoSecond, 9) case code == "second": fp.addFormatFunc(ioOutputFormatSecond, 2) case code == "minute": fp.addFormatFunc(ioOutputFormatMinute, 2) case code == "hour": fp.addFormatFunc(ioOutputFormatHour, 2) case code == "day": fp.addFormatFunc(ioOutputFormatDay, 2) case code == "month": fp.addFormatFunc(ioOutputFormatMonth, 2) case code == "year": fp.addFormatFunc(ioOutputFormatYear, 4) case code == "epoch": fp.addFormatFunc(ioOutputFormatEpoch, 10) case code == "tzoffset": fp.addFormatFunc(ioOutputFormatTZOffset, 5) case code == "tz": fp.addFormatFunc(ioOutputFormatTZ, 4) // System level tools. case code == "hostname": fp.addFormatFunc(ioOutputFormatHostname, 4) case code == "pid": fp.addFormatFunc(ioOutputFormatPid, 0) // Calling code fields. case code == "package": fp.addFormatFunc(ioOutputFormatPackage, 0) case code == "function": fp.addFormatFunc(ioOutputFormatFunction, 0) case code == "sourcefile": fp.addFormatFunc(ioOutputFormatSourceFile, 0) case code == "sourceline": fp.addFormatFunc(ioOutputFormatSourceLine, 0) case code == "json:message": fp.addFormatFunc(ioOutputFormatJsonMessage, 0) // Field access. case strings.HasPrefix(code, "field:"): if len(code) < 7 { return fmt.Errorf("Color code left empty.") } fp.addFormatFunc(ioOutputFormatField(code[6:]), 0) // Color: case strings.HasPrefix(code, "color:"): if len(code) < 7 { return fmt.Errorf("Color code left empty.") } if err := fp.setAnsiColor(code[6:]); err != nil { return err } default: // Unknown return fmt.Errorf("Unknown format code: %s", code) } return nil }
[ "func", "(", "fp", "*", "formatParser", ")", "processCode", "(", "index", "int", ")", "error", "{", "code", ":=", "fp", ".", "format", "[", "fp", ".", "start", "+", "1", ":", "index", "]", "\n", "switch", "{", "case", "code", "==", "\"", "\"", ":...
// Processes codes, adds them to the lastStatic object if necessary, otherwise // adds a function to the function list.
[ "Processes", "codes", "adds", "them", "to", "the", "lastStatic", "object", "if", "necessary", "otherwise", "adds", "a", "function", "to", "the", "function", "list", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L416-L492
17,088
apcera/logray
iooutput.go
setAnsiColor
func (fp *formatParser) setAnsiColor(name string) error { // If colors are not enabled then do not add strings in this function. if fp.color == false { return nil } if ansi, ok := ioOutputColorMap[name]; ok { fp.addStatic(ansi) return nil } else if name == "class" { // 10 bytes is a sane upper bound. fp.addFormatFunc(ioOutputFormatClassColor, 10) return nil } return fmt.Errorf("Unknown color name: %s", name) }
go
func (fp *formatParser) setAnsiColor(name string) error { // If colors are not enabled then do not add strings in this function. if fp.color == false { return nil } if ansi, ok := ioOutputColorMap[name]; ok { fp.addStatic(ansi) return nil } else if name == "class" { // 10 bytes is a sane upper bound. fp.addFormatFunc(ioOutputFormatClassColor, 10) return nil } return fmt.Errorf("Unknown color name: %s", name) }
[ "func", "(", "fp", "*", "formatParser", ")", "setAnsiColor", "(", "name", "string", ")", "error", "{", "// If colors are not enabled then do not add strings in this function.", "if", "fp", ".", "color", "==", "false", "{", "return", "nil", "\n", "}", "\n", "if", ...
// Adds a static string with the given ANSI color code.
[ "Adds", "a", "static", "string", "with", "the", "given", "ANSI", "color", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L495-L509
17,089
apcera/logray
iooutput.go
ioOutputFormatClass
func ioOutputFormatClass(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(strings.ToUpper(ld.Class.String())) return err }
go
func ioOutputFormatClass(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(strings.ToUpper(ld.Class.String())) return err }
[ "func", "ioOutputFormatClass", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "strings", ".", "ToUpper", "(", "ld", ".", "Class", ".", "String", "(", ")", "...
// Formatting function used to implement the %class% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%class%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L512-L515
17,090
apcera/logray
iooutput.go
ioOutputFormatClassFixed
func ioOutputFormatClassFixed(ld *LineData, b *bytes.Buffer) error { class := strings.ToUpper(ld.Class.String()) switch len(class) { case 4: class += " " case 6: class = class[:5] } _, err := b.WriteString(class) return err }
go
func ioOutputFormatClassFixed(ld *LineData, b *bytes.Buffer) error { class := strings.ToUpper(ld.Class.String()) switch len(class) { case 4: class += " " case 6: class = class[:5] } _, err := b.WriteString(class) return err }
[ "func", "ioOutputFormatClassFixed", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "class", ":=", "strings", ".", "ToUpper", "(", "ld", ".", "Class", ".", "String", "(", ")", ")", "\n", "switch", "len", "(", "cl...
// Formatting function used to implement the %classfixed% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%classfixed%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L518-L528
17,091
apcera/logray
iooutput.go
ioOutputFormatMessage
func ioOutputFormatMessage(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.Message) return err }
go
func ioOutputFormatMessage(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.Message) return err }
[ "func", "ioOutputFormatMessage", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "ld", ".", "Message", ")", "\n", "return", "err", "\n", "}" ]
// Formatting function used to implement the %message% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%message%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L531-L534
17,092
apcera/logray
iooutput.go
ioOutputFormatNanoSecond
func ioOutputFormatNanoSecond(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%09d", ld.TimeStamp.Nanosecond())) return err }
go
func ioOutputFormatNanoSecond(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%09d", ld.TimeStamp.Nanosecond())) return err }
[ "func", "ioOutputFormatNanoSecond", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "TimeStamp", ".", ...
// Formatting function used to implement the %nanosecond% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%nanosecond%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L537-L540
17,093
apcera/logray
iooutput.go
ioOutputFormatSecond
func ioOutputFormatSecond(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Second())) return err }
go
func ioOutputFormatSecond(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Second())) return err }
[ "func", "ioOutputFormatSecond", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "TimeStamp", ".", "Se...
// Formatting function used to implement the %second% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%second%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L543-L546
17,094
apcera/logray
iooutput.go
ioOutputFormatMinute
func ioOutputFormatMinute(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Minute())) return err }
go
func ioOutputFormatMinute(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Minute())) return err }
[ "func", "ioOutputFormatMinute", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "TimeStamp", ".", "Mi...
// Formatting function used to implement the %minute% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%minute%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L549-L552
17,095
apcera/logray
iooutput.go
ioOutputFormatHour
func ioOutputFormatHour(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Hour())) return err }
go
func ioOutputFormatHour(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Hour())) return err }
[ "func", "ioOutputFormatHour", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "TimeStamp", ".", "Hour...
// Formatting function used to implement the %hour% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%hour%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L555-L558
17,096
apcera/logray
iooutput.go
ioOutputFormatDay
func ioOutputFormatDay(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Day())) return err }
go
func ioOutputFormatDay(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Day())) return err }
[ "func", "ioOutputFormatDay", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "TimeStamp", ".", "Day",...
// Formatting function used to implement the %day% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%day%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L561-L564
17,097
apcera/logray
iooutput.go
ioOutputFormatMonth
func ioOutputFormatMonth(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", int(ld.TimeStamp.Month()))) return err }
go
func ioOutputFormatMonth(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%02d", int(ld.TimeStamp.Month()))) return err }
[ "func", "ioOutputFormatMonth", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "int", "(", "ld", ".", "TimeStamp...
// Formatting function used to implement the %month% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%month%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L567-L570
17,098
apcera/logray
iooutput.go
ioOutputFormatYear
func ioOutputFormatYear(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%04d", ld.TimeStamp.Year())) return err }
go
func ioOutputFormatYear(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%04d", ld.TimeStamp.Year())) return err }
[ "func", "ioOutputFormatYear", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "TimeStamp", ".", "Year...
// Formatting function used to implement the %year% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%year%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L573-L576
17,099
apcera/logray
iooutput.go
ioOutputFormatEpoch
func ioOutputFormatEpoch(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%d", int(ld.TimeStamp.Unix()))) return err }
go
func ioOutputFormatEpoch(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%d", int(ld.TimeStamp.Unix()))) return err }
[ "func", "ioOutputFormatEpoch", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "int", "(", "ld", ".", "TimeStamp...
// Formatting function used to implement the %epoch% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%epoch%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L579-L582