Documentation ¶
Index ¶
- Variables
- func CmdLogs(query *CMDLogQuery, envID string, settings *models.Settings, il ILogs, ...) error
- type CMDLogQuery
- type ILogs
- type LogMessage
- type SLogs
- func (l *SLogs) Output(queryString, domain string, generator queryGenerator, from int, ...) (int, error)
- func (l *SLogs) RetrieveElasticsearchVersion(domain string) (string, error)
- func (l *SLogs) Stream(queryString, domain string, generator queryGenerator, from int, ...) error
- func (l *SLogs) Watch(queryString, domain string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = models.Command{ Name: "logs", ShortHelp: "Show the logs in your terminal streamed from your logging dashboard", LongHelp: "<code>logs</code> prints out your application logs directly from your logging Dashboard. " + "If you do not see your logs, try adjusting the number of hours, minutes, or seconds of logs that are retrieved with the <code>--hours</code>, <code>--minutes</code>, and <code>--seconds</code> options respectively. " + "To specify a specific service, job, or target use the '--service', '--job-id', and '--target' commands. " + "You must specify a service to use '--job-id' or '--target', and you cannot specify both a job-id and a target at the same time. " + "You can also follow the logs with the <code>-f</code> option. " + "When using <code>-f</code> all logs will be printed to the console within the given time frame as well as any new logs that are sent to the logging Dashboard for the duration of the command. " + "When using the <code>-f</code> option, hit ctrl-c to stop. Here are some sample commands\n\n" + "<pre>\ndatica -E \"<your_env_name>\" logs --hours=6 --minutes=30\n" + "datica -E \"<your_env_name>\" logs -f\n" + "datica -E \"<your_env_name>\" logs --service=\"<your_service_name>\"\n" + "datica -E \"<your_env_name>\" logs --service=\"<your_service_name>\" --job-id=\"<your_job_id>\"\n</pre>", CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) { return func(cmd *cli.Cmd) { query := cmd.StringArg("QUERY", "*", "The query to send to your logging dashboard's elastic search (regex is supported)") follow := cmd.BoolOpt("f follow", false, "Tail/follow the logs (Equivalent to -t)") tail := cmd.BoolOpt("t tail", false, "Tail/follow the logs (Equivalent to -f)") hours := cmd.IntOpt("hours", 0, "The number of hours before now (in combination with minutes and seconds) to retrieve logs") mins := cmd.IntOpt("minutes", 0, "The number of minutes before now (in combination with hours and seconds) to retrieve logs") secs := cmd.IntOpt("seconds", 0, "The number of seconds before now (in combination with hours and minutes) to retrieve logs") service := cmd.StringOpt("service", "", "Query logs for a specific service label") jobID := cmd.StringOpt("job-id", "", "Query logs for a particular job by id") target := cmd.StringOpt("target", "", "Query logs for a particular procfile target") cmd.Action = func() { if _, err := auth.New(settings, prompts.New()).Signin(); err != nil { logrus.Fatal(err.Error()) } if err := config.CheckRequiredAssociation(settings); err != nil { logrus.Fatal(err.Error()) } cmdQuery := CMDLogQuery{ Query: *query, Follow: *follow || *tail, Hours: *hours, Minutes: *mins, Seconds: *secs, Service: *service, JobID: *jobID, Target: *target, } err := CmdLogs(&cmdQuery, settings.EnvironmentID, settings, New(settings), prompts.New(), environments.New(settings), services.New(settings), jobs.New(settings), sites.New(settings)) if err != nil { logrus.Fatal(err.Error()) } } cmd.Spec = "[QUERY] [(-f | -t)] [--hours] [--minutes] [--seconds] [--service [(--job-id | --target)]]" } }, }
Cmd is the contract between the user and the CLI. This specifies the command name, arguments, and required/optional arguments and flags for the command.
Functions ¶
func CmdLogs ¶
func CmdLogs(query *CMDLogQuery, envID string, settings *models.Settings, il ILogs, ip prompts.IPrompts, ie environments.IEnvironments, is services.IServices, ij jobs.IJobs, isites sites.ISites) error
CmdLogs is a way to stream logs from Kibana to your local terminal. This is useful because Kibana is hard to look at because it splits every single log statement into a separate block that spans multiple lines so it's not very cohesive. This is intended to be similar to the `heroku logs` command. TODO: Take out envID? Already present in settings
Types ¶
type CMDLogQuery ¶
type ILogs ¶
type ILogs interface { Output(queryString, domain string, generator queryGenerator, from int, startTimestamp time.Time, endTimestamp time.Time, hostNames []string, fileName string) (int, error) RetrieveElasticsearchVersion(domain string) (string, error) Stream(queryString, domain string, generator queryGenerator, from int, timestamp time.Time, hostNames []string, fileName string) error Watch(queryString, domain string) error }
ILogs ...
type LogMessage ¶
Click to show internal directories.
Click to hide internal directories.