Skip to content

Commit 955091e

Browse files
committed
Document logging via Environment::trace()
1 parent a6685be commit 955091e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ class Greet extends Handler {
5858
}
5959
```
6060

61+
### Logging
62+
63+
To write output to the lambda's log stream, use *trace()*:
64+
65+
```php
66+
use com\amazon\aws\lambda\Handler;
67+
68+
class Greet extends Handler {
69+
70+
/** @return com.amazon.aws.lambda.Lambda|callable */
71+
public function target() {
72+
return function($event, $context) {
73+
$this->environment->trace('Invoked with ', $event);
74+
75+
return sprintf(/* Shortened for brevity */);
76+
};
77+
}
78+
}
79+
```
80+
81+
Any non-string arguments passed will be converted to string using `util.Objects::stringOf()`.
82+
6183
The lambda's environment accessible via *$this->environment* is an Environment instance, see [below](https://github.com/xp-forge/lambda#environment).
6284

6385
Development

0 commit comments

Comments
 (0)