Skip to content

Commit f6ec566

Browse files
authored
DOCS-4470: Remove hello world module (#4720)
1 parent 5bc14c5 commit f6ec566

File tree

9 files changed

+898
-1244
lines changed

9 files changed

+898
-1244
lines changed

assets/how-tos/hello-sensor.png

-34.6 KB
Binary file not shown.
-222 KB
Binary file not shown.

docs/dev/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ result, err := myButton.DoCommand(context.Background(), command)
397397
Using the Viam Registry you can create _{{< glossary_tooltip term_id="resource" text="resources" >}}_ for additional hardware types or models and then deploy them to your machines.
398398
You can use an existing component or service type or create generic resources.
399399

400-
[Create a module →](/operate/modules/support-hardware/hello-world-module/)
400+
[Create a module →](/operate/modules/support-hardware/)
401401

402402
</div>
403403
</div>

docs/operate/modules/advanced/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ For full examples, see [<file>ackermann.py</file>](https://github.com/mcvella/vi
179179
Most Go modules use `resource.AlwaysRebuild` within the `<module-name><resource-name>` struct, which means that the resource rebuilds every time the module is reconfigured.
180180

181181
The steps above use `resource.AlwaysRebuild`.
182-
If you need to maintain the state of your resource, see [(Optional) Create and edit a `Reconfigure` function](/operate/modules/support-hardware/#implement-the-component-api).
182+
If you need to maintain the state of your resource, see [(Optional) Create and edit a `Reconfigure` function](/operate/modules/support-hardware/#implement-api-methods).
183183

184184
{{% /alert %}}
185185

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: "Module logging"
3+
linkTitle: "Module logging"
4+
weight: 45
5+
layout: "docs"
6+
type: "docs"
7+
description: "Use logging with modules"
8+
---
9+
10+
From modules you can log messages at the [resource level](#resource-level-logging) or at the [machine level](#machine-level-logging).
11+
12+
## Resource-level logging
13+
14+
The following log severity levels are available for resource logs:
15+
16+
{{< tabs >}}
17+
{{% tab name="Python" %}}
18+
19+
```python {class="line-numbers linkable-line-numbers"}
20+
# Within some method, log information:
21+
self.logger.debug("debug info")
22+
self.logger.info("info")
23+
self.logger.warn("warning info")
24+
self.logger.error("error info")
25+
self.logger.exception("error info", exc_info=True)
26+
self.logger.critical("critical info")
27+
```
28+
29+
{{% /tab %}}
30+
{{% tab name="Go" %}}
31+
32+
```go {class="line-numbers linkable-line-numbers"}
33+
fn (c *component) someFunction(ctx context.Context, a int) {
34+
// Log with severity info:
35+
c.logger.CInfof(ctx, "performing some function with a=%v", a)
36+
// Log with severity debug (using value wrapping):
37+
c.logger.CDebugw(ctx, "performing some function", "a" ,a)
38+
// Log with severity warn:
39+
c.logger.CWarnw(ctx, "encountered warning for component", "name", c.Name())
40+
// Log with severity error without a parameter:
41+
c.logger.CError(ctx, "encountered an error")
42+
}
43+
```
44+
45+
{{% /tab %}}
46+
{{< /tabs >}}
47+
48+
Resource-level logs are recommended instead of global logs for modular resources, because they make it easier to determine which component or service an error is coming from.
49+
Resource-level error logs appear in the <strong>ERROR LOGS</strong> section of each resource's configuration card in the app.
50+
51+
{{% alert title="Note" color="note" %}}
52+
In order to see resource-level debug logs when using your modular resource, you'll either need to run `viam-server` with the `-debug` option or [configure your machine or individual resource to display debug logs](/operate/reference/viam-server/#logging).
53+
{{% /alert %}}
54+
55+
## Machine-level logging
56+
57+
If you need to publish to the global machine-level logs instead of using the recommended resource-level logging, you can follow this example:
58+
59+
```python {class="line-numbers linkable-line-numbers" data-line="2,5"}
60+
# In your import block, import the logging package:
61+
from viam.logging import getLogger
62+
63+
# Before your first class or function, define the LOGGER variable:
64+
LOGGER = getLogger(__name__)
65+
66+
# in some method, log information
67+
LOGGER.debug("debug info")
68+
LOGGER.info("info info")
69+
LOGGER.warn("warn info")
70+
LOGGER.error("error info")
71+
LOGGER.exception("error info", exc_info=True)
72+
LOGGER.critical("critical info")
73+
```

docs/operate/modules/support-hardware/_index.md

Lines changed: 820 additions & 524 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)