You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Why don't I see `console.log` from my component outside `oc dev`?
160
+
161
+
In local development (`oc dev`), the registry runs with `local: true` and forwards component `console.*` calls to the process console. On a normal (non-local) registry — including staging and production with remote storage — those calls are discarded.
162
+
163
+
This is by design. `local` is **not** a "use filesystem storage" flag you can flip in lower environments to get logs back. Setting `local: true` on a deployed registry also disables publishing and changes other production behaviour.
164
+
165
+
For intentional logging in any environment, register a logging plugin and call it from `server.js`. See [Logging from components](../registry/registry-configuration#logging-from-components).
| <sub>discovery</sub> | boolean | no |`true`| Enables the HTML discovery page and `/components` endpoint |
131
131
| <sub>discoveryFunc</sub> | function | no | - | Function to decide whether discovery should be enabled for the current request. Function signature: `(opts: { host?: string; secure: boolean }) => boolean`|
132
-
| <sub>local</sub> | boolean | no | - |Indicates whether the registry serves components from the local file system (`true`) or from remote storage (`false`) |
133
-
| <sub>path</sub> | string | no | - | Absolute path where local components are stored (used when `local` is `true`)|
134
-
| <sub>hotReloading</sub> | boolean | no |`!!local`| Enables hot-reloading of component code. Always `true` when `local` is `true`|
132
+
| <sub>local</sub> | boolean | no | - |Enables **local development mode** (what `oc dev` sets). Not a storage selector — see [Local development mode](#local-development-mode)|
133
+
| <sub>path</sub> | string | no | - | Absolute path where local components are stored (required when `local` is `true`) |
134
+
| <sub>hotReloading</sub> | boolean | no |`!!local`| Enables hot-reloading of component code. Defaults to `true` when `local` is `true`|
135
135
| <sub>liveReloadPort</sub> | number | no | - | TCP port of the LiveReload server used by the preview page |
136
136
| <sub>compileClient</sub> | boolean or object | no |`true`| Set options for the oc-client-browser compilation. Set to `false` to disable client compilation, or provide options object for custom compilation settings |
137
137
@@ -255,6 +255,8 @@ registry.start();
255
255
256
256
### Local Development Configuration
257
257
258
+
Prefer `oc dev` over hand-rolling this. The CLI starts a registry with `local: true` and the right defaults for day-to-day component work.
259
+
258
260
```js
259
261
var oc =require("oc");
260
262
@@ -274,6 +276,22 @@ var registry = new oc.Registry(configuration);
274
276
registry.start();
275
277
```
276
278
279
+
#### Local development mode
280
+
281
+
`local: true` turns on **local development mode**. It is **not** a toggle between "filesystem storage" and "remote storage" that you would flip in staging or production.
282
+
283
+
When `local` is `true`, the registry:
284
+
285
+
- Serves components from a local directory (`path`) instead of a storage adapter
286
+
-**Disables publishing** — components cannot be published to a local registry
287
+
- Enables hot-reloading of component code (unless you override `hotReloading`)
288
+
- Forwards component `console.*` calls to the process console (so `console.log` in `server.js` is visible while developing)
289
+
- Sets `NODE_ENV` to `development` inside the component sandbox
290
+
- Surfaces richer server-side error details (including processed stack frames) in responses and logs
291
+
- Skips storage/metadata validation that production registries require
292
+
293
+
Do **not** set `local: true` on a deployed registry to get component logs or filesystem-like behaviour. You will lose publishing and change other production semantics. For intentional logging outside `oc dev`, use a [logging plugin](#logging-from-components).
294
+
277
295
### Custom Storage Adapter Configuration
278
296
279
297
```js
@@ -462,14 +480,11 @@ module.exports.execute = function (context) {
462
480
returnconnection.get(featureName);
463
481
};
464
482
};
465
-
466
-
// Enable context awareness
467
-
module.exports.context=true;
468
483
```
469
484
470
485
### Plugin Registration
471
486
472
-
This is how to register plugins in a registry:
487
+
This is how to register plugins in a registry. Context awareness is enabled with `context: true` on the **registration** object (not on the plugin module):
473
488
474
489
```js
475
490
// ./registry/init.js
@@ -488,6 +503,7 @@ registry.register({
488
503
// Register a context-aware plugin
489
504
registry.register({
490
505
name:"getSecureFeature",
506
+
context:true,
491
507
register:require("./oc-plugins/feature-flags"),
492
508
options: {
493
509
connectionString: connectionString,
@@ -512,6 +528,78 @@ module.exports.data = function (context, callback) {
512
528
};
513
529
```
514
530
531
+
### Logging from components
532
+
533
+
Outside `oc dev`, component `console.log` / `console.error` / etc. are discarded. That is intentional: the registry sandbox does not ship every component's unstructured console output into production process logs.
534
+
535
+
`local: true` is not a production logging switch (see [Local development mode](#local-development-mode)). For logging in staging or production, register a plugin and call it from `server.js`.
0 commit comments