MCPcopy Create free account
hub / github.com/aws/aws-sam-cli / format_examples

Method format_examples

samcli/commands/logs/core/command.py:23–90  ·  view source on GitHub ↗
(ctx: Context, formatter: CommandHelpTextFormatter)

Source from the content-addressed store, hash-verified

21
22 @staticmethod
23 def format_examples(ctx: Context, formatter: CommandHelpTextFormatter):
24 with formatter.indented_section(name="Examples", extra_indents=1):
25 with formatter.indented_section(
26 name="Fetch logs with Lambda Function Logical ID and Cloudformation Stack Name"
27 ):
28 formatter.write_text_rows(
29 [
30 RowDefinition(
31 name=style(f"$ {ctx.command_path} -n HelloWorldFunction --stack-name mystack"),
32 extra_row_modifiers=[ShowcaseRowModifier()],
33 ),
34 ]
35 )
36 with formatter.indented_section(name="View logs for specific time range"):
37 formatter.write_text_rows(
38 [
39 RowDefinition(
40 name=style(
41 f"$ {ctx.command_path} -n HelloWorldFunction --stack-name mystack -s "
42 f"'10min ago' -e '2min ago'"
43 ),
44 extra_row_modifiers=[ShowcaseRowModifier()],
45 ),
46 ]
47 )
48 with formatter.indented_section(name="Tail new logs"):
49 formatter.write_text_rows(
50 [
51 RowDefinition(
52 name=style(f"$ {ctx.command_path} -n HelloWorldFunction --stack-name " f"mystack --tail"),
53 extra_row_modifiers=[ShowcaseRowModifier()],
54 ),
55 ]
56 )
57 with formatter.indented_section(name="Fetch from Cloudwatch log groups"):
58 formatter.write_text_rows(
59 [
60 RowDefinition(
61 name=style(
62 f"$ {ctx.command_path} --cw-log-group /aws/lambda/myfunction-123 "
63 f"--cw-log-group /aws/lambda/myfunction-456"
64 ),
65 extra_row_modifiers=[ShowcaseRowModifier()],
66 ),
67 ]
68 )
69
70 with formatter.indented_section(name="Fetch logs from supported resources in Cloudformation stack"):
71 formatter.write_text_rows(
72 [
73 RowDefinition(
74 name=style(f"$ {ctx.command_path} ---stack-name mystack"),
75 extra_row_modifiers=[ShowcaseRowModifier()],
76 ),
77 ]
78 )
79
80 with formatter.indented_section(name="Fetch logs from resource defined in nested Cloudformation stack"):

Callers 2

format_optionsMethod · 0.45

Calls 4

RowDefinitionClass · 0.90
ShowcaseRowModifierClass · 0.90
indented_sectionMethod · 0.45
write_text_rowsMethod · 0.45

Tested by 1