Documentation
¶
Index ¶
- Constants
- type Application
- type Argument
- type Arguments
- type Command
- func (c *Command) Arguments() []Argument
- func (c *Command) BindConnection(conn net.Conn)
- func (c *Command) GetOrigin() string
- func (c *Command) Response(result []byte) porterr.IError
- func (c *Command) Result(result []byte) porterr.IError
- func (c *Command) String() string
- func (c *Command) UnbindConnection()
- type DNApp
- func (a DNApp) AttentionMessage(message string, command ...*Command)
- func (a DNApp) FailMessage(message string, command ...*Command)
- func (a DNApp) FatalError(err error)
- func (a DNApp) GetAbsolutePath(path string, dir string) (string, porterr.IError)
- func (a DNApp) GetConfig() interface{}
- func (a DNApp) GetConfigPath(env string) string
- func (a *DNApp) GetLogger() Logger
- func (a *DNApp) ParseConfig(env string) Application
- func (a DNApp) ParseFlags(args *Arguments)
- func (a *DNApp) SetConfig(cfg interface{}) Application
- func (a *DNApp) SetLogger(logger Logger)
- func (a DNApp) Start(address string, callback func(command *Command)) porterr.IError
- func (a DNApp) SuccessMessage(message string, command ...*Command)
- type Logger
- type LoggerConfig
- type LoggerFormat
Constants ¶
const ( ArgumentTypeString = "string" ArgumentTypeInt = "int" ArgumentTypeUint = "uint" ArgumentTypeBool = "bool" )
const ( CommandPrefix = "-" CommandAssignee = "=" CommandDelimiter = ";" )
const ( LogLevelDebug = 1 << iota LogLevelInfo LogLevelWarn LogLevelErr DefaultCallDepth = 3 DefaultKeyLoggerPrefix = "prefix" )
const ( CommandSessionHost = "localhost" CommandSessionPort = "8080" CommandSessionType = "tcp" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface {
// GetConfig Get config struct
GetConfig() interface{}
// GetConfigPath Get full path to config
GetConfigPath(env string) string
// GetAbsolutePath Get absolute path
GetAbsolutePath(path string, dir string) (string, porterr.IError)
// SetConfig Set config struct
SetConfig(cfg interface{}) Application
// ParseConfig Parse config
ParseConfig(env string) Application
// Start run application
Start(port string, callback func(command *Command)) porterr.IError
// FatalError Behaviour for fatal errors
FatalError(err error)
// GetLogger Get Logger
GetLogger() Logger
// SetLogger set custom logger
SetLogger(logger Logger)
// SuccessMessage Success log message with command repeat
SuccessMessage(message string, command ...*Command)
// AttentionMessage Warning log message with command repeat
AttentionMessage(message string, command ...*Command)
// FailMessage Fail log message with command repeat
FailMessage(message string, command ...*Command)
// ParseFlags Parse console flags
ParseFlags(args *Arguments)
}
Application interface
func NewApplication ¶ added in v0.5.0
func NewApplication(env string, configPath string, values interface{}) Application
NewApplication Create new Application
type Argument ¶
type Argument struct {
// Type of argument
Type string
// Value of argument
Value interface{}
// Label of argument
Label string
// Name of argument
Name string
}
Argument struct
type Command ¶ added in v0.4.0
type Command struct {
// contains filtered or unexported fields
}
Command is an argument list
func ParseCommand ¶ added in v0.4.0
ParseCommand Parse command
func (*Command) BindConnection ¶ added in v0.4.0
BindConnection Bind connection to command
func (*Command) UnbindConnection ¶ added in v0.4.0
func (c *Command) UnbindConnection()
UnbindConnection UnBind connection
type DNApp ¶
type DNApp struct {
// contains filtered or unexported fields
}
DNApp Dynamic Name Application Implements Application interface
func (DNApp) AttentionMessage ¶ added in v0.6.0
AttentionMessage printing attention message
func (DNApp) FailMessage ¶ added in v0.6.0
FailMessage printing fail message
func (DNApp) GetAbsolutePath ¶ added in v0.5.0
GetAbsolutePath Get absolute path to application
func (DNApp) GetConfigPath ¶
GetConfigPath Get full path to config
func (*DNApp) ParseConfig ¶ added in v0.5.0
func (a *DNApp) ParseConfig(env string) Application
ParseConfig parse config depends on env
func (DNApp) ParseFlags ¶
ParseFlags parse console arguments
func (*DNApp) SetConfig ¶
func (a *DNApp) SetConfig(cfg interface{}) Application
SetConfig Set config struct
func (DNApp) SuccessMessage ¶ added in v0.6.0
SuccessMessage printing success message
type Logger ¶ added in v0.0.7
type Logger interface {
GetConfig() LoggerConfig
Output(callDepth int, message string) error
Print(v ...interface{})
Println(v ...interface{})
Printf(format string, v ...interface{})
Info(v ...interface{})
Infoln(v ...interface{})
Infof(format string, v ...interface{})
Warn(v ...interface{})
Warnln(v ...interface{})
Warnf(format string, v ...interface{})
Error(v ...interface{})
Errorln(v ...interface{})
Errorf(format string, v ...interface{})
}
Logger Common logger interface
type LoggerConfig ¶ added in v0.9.0
type LoggerConfig struct {
// Level of log message
Level int
// Default is 2
Depth int
// Flags
Flags int
// Format for multiple arguments
Format LoggerFormat
}
LoggerConfig configuration of logger
type LoggerFormat ¶ added in v0.9.0
LoggerFormat logger prefix
func (LoggerFormat) FromContext ¶ added in v0.9.0
func (lf LoggerFormat) FromContext(ctx context.Context) string
FromContext create log prefix from context
func (LoggerFormat) String ¶ added in v0.9.0
func (lf LoggerFormat) String() string
String serialize format to string