Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit e95c34a

Browse files
authored
feat(logs): Use debug.js library for logging [DXJ-327] (#285)
1 parent 43f39d5 commit e95c34a

File tree

27 files changed

+7272
-842
lines changed

27 files changed

+7272
-842
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,57 @@ Once you've added the client, you can compile [Aqua](https://github.com/fluencel
139139
}
140140
```
141141

142+
## Debug
143+
144+
JS Client uses the [debug](https://github.com/debug-js/debug) library under the hood for logging. The log namespaces are structured on a per-component basis, following this structure:
145+
146+
```
147+
fluence:<component>:trace
148+
fluence:<component>:debug
149+
fluence:<component>:error
150+
```
151+
152+
Marine JS logs have a slightly different structure:
153+
154+
```
155+
fluence:marine:<service id>:trace
156+
fluence:marine:<service id>:debug
157+
fluence:marine:<service id>:info
158+
fluence:marine:<service id>:warn
159+
fluence:marine:<service id>:error
160+
```
161+
162+
Each level corresponds to a logging level in Marine JS.
163+
164+
Star (`*`) character can be used as a wildcard to enable logs for multiple components at once. For example, `DEBUG=fluence:*` will enable logs for all components. To exclude a component, use a minus sign before the component name. For example, `DEBUG=fluence:*,-fluence:particle:*`
165+
166+
### Index of components:
167+
168+
- `particle`: everything related to particle processing queue
169+
- `aqua`: infrastructure of aqua compiler support
170+
- `connection`: connection layer
171+
- `marine`: Marine JS logs
172+
173+
### Enabling logs in Node.js
174+
175+
enable logs, pass the environment variable `DEBUG` with the corresponding log level. For example:
176+
177+
```sh
178+
DEBUG=fluence:* node --loader ts-node/esm ./src/index.ts
179+
```
180+
181+
### Enabling logs in the browser
182+
183+
To enable logs, set the `localStorage.debug` variable. For example:
184+
185+
```
186+
localStorage.debug = 'fluence:*'
187+
```
188+
189+
**NOTE**
190+
191+
In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by debug if the "Verbose" log level is enabled.
192+
142193
## Development
143194

144195
To hack on the Fluence JS Client itself, please refer to the [development page](./DEVELOPING.md).
@@ -159,3 +210,4 @@ Any interested person is welcome to contribute to the project. Please, make sure
159210
## License
160211

161212
All software code is copyright (c) Fluence Labs, Inc. under the [Apache-2.0](./LICENSE) license.
213+

packages/@tests/aqua/_aqua/smoke_test.aqua

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,53 @@ import "@fluencelabs/registry/resources-api.aqua"
33
service HelloWorld("hello-world"):
44
hello(str: string) -> string
55

6-
func smokeTest(label: string) -> ?string, *string, string:
6+
func resourceTest(label: string) -> ?string, *string:
77
res, errors <- createResource(label)
8+
<- res, errors
9+
10+
func helloTest() -> string:
811
hello <- HelloWorld.hello("Fluence user")
9-
<- res, errors, hello
12+
<- hello
13+
14+
service CalcService:
15+
add(num: f64) -> f64
16+
clear_state()
17+
divide(num: f64) -> f64
18+
multiply(num: f64) -> f64
19+
state() -> f64
20+
subtract(num: f64) -> f64
21+
test_logs()
22+
23+
data ServiceCreationResult:
24+
success: bool
25+
service_id: ?string
26+
error: ?string
27+
28+
data RemoveResult:
29+
success: bool
30+
error: ?string
31+
32+
alias ListServiceResult: []string
33+
34+
service Srv("single_module_srv"):
35+
create(wasm_b64_content: string) -> ServiceCreationResult
36+
remove(service_id: string) -> RemoveResult
37+
list() -> ListServiceResult
38+
39+
40+
func demo_calculation(service_id: string) -> f64:
41+
CalcService service_id
42+
CalcService.test_logs()
43+
CalcService.add(10)
44+
CalcService.multiply(5)
45+
CalcService.subtract(8)
46+
CalcService.divide(6)
47+
res <- CalcService.state()
48+
<- res
49+
50+
func marineTest(wasm64: string) -> f64:
51+
serviceResult <- Srv.create(wasm64)
52+
res <- demo_calculation(serviceResult.service_id!)
53+
<- res
54+
55+

packages/@tests/aqua/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "module",
1212
"scripts": {
1313
"build": "tsc",
14-
"compile-aqua": "aqua -i ./_aqua -o ./src/_aqua"
14+
"compile-aqua": "fluence aqua -i ./_aqua -o ./src/_aqua"
1515
},
1616
"repository": "https://github.com/fluencelabs/fluence-js",
1717
"author": "Fluence Labs",
@@ -22,7 +22,9 @@
2222
"base64-js": "1.5.1"
2323
},
2424
"devDependencies": {
25-
"@fluencelabs/aqua": "0.9.4",
26-
"@fluencelabs/registry": "0.7.0"
25+
"@fluencelabs/cli": "0.3.9",
26+
"@fluencelabs/registry": "0.8.2",
27+
"@fluencelabs/aqua-lib": "0.6.0",
28+
"@fluencelabs/trust-graph": "3.1.2"
2729
}
2830
}

0 commit comments

Comments
 (0)