GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Aframe-nft/src/logLevel.js at main · webarkit/Aframe-nft

Expand file tree

/

logLevel.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
40 lines (36 loc) · 1.38 KB
/

logLevel.js

Copy path

File metadata and controls

40 lines (36 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* The `arnft` system's `logLevel` attribute, mapped to jsartoolkitNFT's
* `ARLogLevel`.
*
* The numbers mirror the `ARLogLevel` enum exported by
* `@webarkit/jsartoolkit-nft`, where lower is more verbose. They are
* duplicated here rather than imported so this module stays free of the
* tracker bundle and can be unit-tested in isolation.
*
* @module logLevel
*/
const AR_LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
/** Used when the attribute is not set, and for unknown names. */
export const DEFAULT_LOG_LEVEL = 'warn';
/** The accepted `logLevel` names, most verbose first. */
export const LOG_LEVEL_NAMES = Object.keys(AR_LOG_LEVELS);
/**
* Convert a `logLevel` name to jsartoolkitNFT's numeric `ARLogLevel`.
*
* A-Frame does not enforce a schema's `oneOf`, so a mistyped value reaches this
* function. It then falls back to {@link DEFAULT_LOG_LEVEL} and warns once.
*
* @param {string} name `debug`, `info`, `warn` or `error`; case is ignored.
* @returns {number} The `ARLogLevel` value.
*/
export function toARLogLevel(name) {
const key = String(name).toLowerCase();
if (Object.hasOwn(AR_LOG_LEVELS, key)) {
return AR_LOG_LEVELS[key];
}
console.warn(
`arnft: unknown logLevel "${name}"; using "${DEFAULT_LOG_LEVEL}". ` +
`Use one of: ${LOG_LEVEL_NAMES.join(', ')}.`,
);
return AR_LOG_LEVELS[DEFAULT_LOG_LEVEL];
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.