Initialisation
Added the packages and files for the backend server
This commit is contained in:
27
node_modules/loglevel/.editorconfig
generated
vendored
Normal file
27
node_modules/loglevel/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
# EditorConfig defines and maintains consistent coding styles between different
|
||||
# editors and IDEs: http://EditorConfig.org/
|
||||
# Top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# All files
|
||||
[*.*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 80
|
||||
|
||||
[*.md]
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
|
||||
[vendor/grunt-template-jasmine-requirejs/**/*]
|
||||
indent_size = 2
|
||||
98
node_modules/loglevel/CONTRIBUTING.md
generated
vendored
Normal file
98
node_modules/loglevel/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
Filing tickets against loglevel
|
||||
===============================
|
||||
|
||||
If you'd like to file a bug or a feature request for loglevel, the best option is to [open an issue on Github](https://github.com/pimterry/loglevel/issues/new).
|
||||
|
||||
If you're filing a feature request, please remember:
|
||||
|
||||
* Feature requests significantly expanding the scope of loglevel outside the description in [the readme](https://github.com/pimterry/loglevel/blob/master/README.md) will probably be rejected.
|
||||
* Features that can't be meaningfully implemented in a cross-environment compatible manner won't be implemented.
|
||||
* Please check the previously opened issues to see if somebody else has suggested it first.
|
||||
* Consider submitting a pull request to add the feature instead, if you're confident it fits within the above.
|
||||
|
||||
If you're filing a bug, please remember:
|
||||
|
||||
* To provide detailed steps to reproduce the behaviour.
|
||||
* If possible, provide a Jasmine test which reproduces the behaviour.
|
||||
* Please specify the exact details of the environment in which it fails: OS + Environment (i.e. Browser or Node) + version.
|
||||
* Consider submitting a pull request to fix the bug instead.
|
||||
|
||||
Helping develop loglevel
|
||||
================================
|
||||
|
||||
If you'd like to help develop loglevel further, please submit a pull request! I'm very keen to improve loglevel further, and good pull requests will be enthusiastically merged.
|
||||
|
||||
Before submitting a pull request to fix a bug or add a new feature, please check the lists above to ensure it'll be accepted. Browser compatibility is particularly important here; if you add a feature or fix a bug which breaks things on other browsers it will not be merged, no matter how awesome it may be.
|
||||
|
||||
To be more specific, before submitting your pull request please ensure:
|
||||
|
||||
* You haven't broken the existing test suite in any obvious browsers (at least check latest IE/FF/Chrome).
|
||||
* You've added relevant tests for the bug you're fixing/the new feature you're adding/etc, which pass in all the relevant browsers.
|
||||
* JSHint is happy with your new code.
|
||||
* You've updated the API docs (in `README.md`) to detail any changes you've made to the public interface.
|
||||
* Your change is backward-compatible (or you've explicitly said that it's not; this isn't great, but will be considered).
|
||||
* You haven't changed any files in `dist/` (these are auto-generated, and should only be changed on release).
|
||||
|
||||
Compatibility and JavaScript Runtimes
|
||||
-------------------------------------
|
||||
|
||||
loglevel aims to stay compatible with browsers, Node.js versions, and other JS runtimes that may be fairly old at this point! Please take care to match existing conventions and JavaScript language features wherever possible. For example, loglevel uses `var` instead of the newer `let` and `const` keywords to define variables, uses old-style `for` loops instead of the newer `for...of` loop, and so on.
|
||||
|
||||
That said, loglevel's *test and development tools* utilize newer JavaScript and Node.js features. To run most tests or build releases, you will need a newer version of Node.js than is required at runtime (see details below in ["how to make your change…"](#how-to-make-your-change-and-submit-it)). Using newer features or making breaking changes to the *dev tools* is OK.
|
||||
|
||||
Project structure
|
||||
-----------------
|
||||
|
||||
The core project code is all in [`lib/loglevel.js`](./lib/loglevel.js), and this should be the only file you need to touch for functional changes themselves.
|
||||
|
||||
The released code is in `dist/*.js`, and should not be touched by anything except releases (pull requests should *not* update these files).
|
||||
|
||||
The test suite is entirely in `test/*.js`:
|
||||
|
||||
* Every file ending in `-test.js` is a unit test, is written in RequireJS, and should pass in any environment.
|
||||
* `global-integration.js` and `node-integration.js` are quick integration smoke tests for node and for browser global usage.
|
||||
* `test-helpers.js` contains some test utilities.
|
||||
* `manual-test.html` is a test page which includes the current loglevel build, so you can manually check that it works in a given browser.
|
||||
|
||||
How to make your change and submit it
|
||||
-------------------------------------
|
||||
|
||||
1. Ensure you have Node.js v14 or later (some tests can run on earlier versions, but the full suite requires this version).
|
||||
2. Fork loglevel.
|
||||
3. Clone your fork locally.
|
||||
4. Create a branch from `master` for your change.
|
||||
5. Write some tests in `test/` for your change, as relevant.
|
||||
6. Make your code changes in `lib/loglevel.js`.
|
||||
7. Check your code all passes (run `npm test`). If you have issues and need to debug the tests, see the details on ["running tests"](#running-tests) below.
|
||||
8. Commit your changes.
|
||||
9. Open a pull request back to `master` in loglevel.
|
||||
|
||||
Running Tests
|
||||
-------------
|
||||
|
||||
There are several types of tests and test tools that loglevel uses to verify different types of support in different environments. When you run `npm test`, *all* of these tests are run automatically. However, you may want to run individual types of tests during development, or run some tests manually to debug them.
|
||||
|
||||
Test commands (see `"scripts"` in `package.json` for a complete list of tools):
|
||||
- `npm test` — Runs all the below tests.
|
||||
- `npm run test-browser` — Runs detailed tests in a headless browser. There are actually 3 sub-groups here:
|
||||
- `npx grunt jasmine:global` — Tests general usage of the global `log` variable.
|
||||
- `npx grunt test-browser-context` — Tests usage when loglevel is injected into an anonymous function instead of included as a regular script on the page.
|
||||
- `npx grunt jasmine:requirejs` — Tests the main test suite via Jasmine & RequireJS.
|
||||
- `npm run test-node` — Runs tests that check loglevel in Node.js.
|
||||
- `npm run test-types` — Runs tests of the TypeScript type definitions for loglevel.
|
||||
|
||||
Alternatively, you might want to run tests manually in your browser in order to use debugging tools to step through the code:
|
||||
1. Run `npx grunt integration-test` to start a test server on port `8000`.
|
||||
2. Your default browser should open the tests automatically, but if not, open `http://127.0.0.1:8000/_SpecRunner.html` in any browser.
|
||||
3. Open your browser's dev tools and place breakpoints where you'd like to debug a test.
|
||||
4. Reload the page to re-run the tests and pause on breakpoints.
|
||||
|
||||
You can also open a blank webpage with loglevel pre-loaded to experiment in your browser's console:
|
||||
1. Run `npx grunt integration-test` to start a test server on port `8000`.
|
||||
2. In whatever browser you want to test, open `http://127.0.0.1:8000/test/manual-test.html`.
|
||||
3. Play around with the global `log` object in the browser's dev console.
|
||||
|
||||
Reporting security issues
|
||||
-------------------------
|
||||
|
||||
Tidelift acts as the security contact for loglevel. Issues can be reported to security@tidelift.com, see https://tidelift.com/security for more details.
|
||||
165
node_modules/loglevel/Gruntfile.js
generated
vendored
Normal file
165
node_modules/loglevel/Gruntfile.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
'use strict';
|
||||
|
||||
var Jasmine = require('jasmine');
|
||||
|
||||
module.exports = function (grunt) {
|
||||
var jasmineRequireJsOptions = {
|
||||
specs: 'test/*-test.js',
|
||||
helpers: 'test/*-helper.js',
|
||||
};
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
// Metadata.
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
banner: '/*! <%= pkg.name %> - v<%= pkg.version %>' +
|
||||
' - <%= pkg.homepage %>' +
|
||||
' - (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
|
||||
' - licensed <%= pkg.license %> */\n',
|
||||
// Task configuration.
|
||||
concat: {
|
||||
options: {
|
||||
banner: '<%= banner %>',
|
||||
stripBanners: true
|
||||
},
|
||||
dist: {
|
||||
src: ['lib/<%= pkg.name %>.js'],
|
||||
dest: 'dist/<%= pkg.name %>.js'
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '<%= banner %>'
|
||||
},
|
||||
dist: {
|
||||
src: '<%= concat.dist.dest %>',
|
||||
dest: 'dist/<%= pkg.name %>.min.js'
|
||||
}
|
||||
},
|
||||
jasmine: {
|
||||
requirejs: {
|
||||
src: [],
|
||||
options: {
|
||||
specs: jasmineRequireJsOptions.specs,
|
||||
helpers: jasmineRequireJsOptions.helpers,
|
||||
template: require('./vendor/grunt-template-jasmine-requirejs')
|
||||
}
|
||||
},
|
||||
global: {
|
||||
src: 'lib/**/*.js',
|
||||
options: {
|
||||
specs: 'test/global-integration.js',
|
||||
}
|
||||
},
|
||||
context: {
|
||||
src: 'test/test-context-using-apply.generated.js',
|
||||
options: {
|
||||
specs: 'test/global-integration-with-new-context.js',
|
||||
}
|
||||
}
|
||||
},
|
||||
jasmine_node: {
|
||||
options: {
|
||||
specs: ['test/node-integration.js']
|
||||
}
|
||||
},
|
||||
open: {
|
||||
jasmine: {
|
||||
path: 'http://127.0.0.1:8000/_SpecRunner.html'
|
||||
}
|
||||
},
|
||||
connect: {
|
||||
test: {
|
||||
port: 8000,
|
||||
keepalive: true
|
||||
}
|
||||
},
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: '.jshintrc'
|
||||
},
|
||||
gruntfile: {
|
||||
src: 'Gruntfile.js'
|
||||
},
|
||||
lib: {
|
||||
options: {
|
||||
jshintrc: 'lib/.jshintrc'
|
||||
},
|
||||
src: ['lib/**/*.js']
|
||||
},
|
||||
test: {
|
||||
options: {
|
||||
jshintrc: 'test/.jshintrc'
|
||||
},
|
||||
src: ['test/*.js', '!test/*.generated.js']
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
gruntfile: {
|
||||
files: '<%= jshint.gruntfile.src %>',
|
||||
tasks: ['jshint:gruntfile']
|
||||
},
|
||||
lib: {
|
||||
files: '<%= jshint.lib.src %>',
|
||||
tasks: ['jshint:lib', 'test']
|
||||
},
|
||||
test: {
|
||||
files: '<%= jshint.test.src %>',
|
||||
tasks: ['jshint:test', 'test']
|
||||
}
|
||||
},
|
||||
preprocess: {
|
||||
"test-context-using-apply": {
|
||||
src: 'test/test-context-using-apply.js',
|
||||
dest: 'test/test-context-using-apply.generated.js'
|
||||
}
|
||||
},
|
||||
clean:{
|
||||
test:['test/test-context-using-apply.generated.js']
|
||||
}
|
||||
});
|
||||
|
||||
// These plugins provide necessary tasks.
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-jasmine');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-open');
|
||||
grunt.loadNpmTasks('grunt-preprocess');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
|
||||
// Run Jasmine with Node.js tests (as opposed to browser tests).
|
||||
//
|
||||
// NOTE: This is designed for Jasmine 2.4, which matches the version used
|
||||
// in `grunt-contrib-jasmine`. If that package is updated, this should also
|
||||
// be updated to match.
|
||||
grunt.registerTask('jasmine_node', 'Run Jasmine in Node.js', function() {
|
||||
var done = this.async();
|
||||
|
||||
var jasmine = new Jasmine({ projectBaseDir: __dirname });
|
||||
jasmine.onComplete(function(success) {
|
||||
done(success);
|
||||
});
|
||||
|
||||
jasmine.execute(this.options().specs);
|
||||
});
|
||||
|
||||
// Build a distributable release
|
||||
grunt.registerTask('dist', ['test', 'dist-build']);
|
||||
grunt.registerTask('dist-build', ['concat', 'uglify']);
|
||||
|
||||
// Check everything is good
|
||||
grunt.registerTask('test', ['jshint', 'test-browser', 'test-node']);
|
||||
grunt.registerTask('test-browser', ['jasmine:global', 'test-browser-context', 'jasmine:requirejs']);
|
||||
grunt.registerTask('test-browser-context', ['preprocess', 'jasmine:context', 'clean:test']);
|
||||
grunt.registerTask('test-node', ['jasmine_node']);
|
||||
|
||||
// Test with a live server and an actual browser
|
||||
grunt.registerTask('integration-test', ['jasmine:requirejs:src:build', 'open:jasmine', 'connect:test:keepalive']);
|
||||
|
||||
// Default task.
|
||||
grunt.registerTask('default', 'test');
|
||||
};
|
||||
22
node_modules/loglevel/LICENSE-MIT
generated
vendored
Normal file
22
node_modules/loglevel/LICENSE-MIT
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2013 Tim Perry
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
408
node_modules/loglevel/README.md
generated
vendored
Normal file
408
node_modules/loglevel/README.md
generated
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
|
||||
# loglevel [![NPM version][npm-image]][npm-url] [](https://www.npmjs.com/package/loglevel) [](https://github.com/pimterry/loglevel/actions/workflows/ci.yml)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/loglevel.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/loglevel
|
||||
|
||||
> _Don't debug with logs alone - check out [HTTP Toolkit](https://httptoolkit.tech/javascript): beautiful, powerful & open-source tools for building, testing & debugging HTTP(S)_
|
||||
|
||||
Minimal lightweight simple logging for JavaScript (browsers, node.js or elsewhere). loglevel extends `console.log()` & friends with level-based logging and filtering, with none of console's downsides.
|
||||
|
||||
Test it out live in your browser console at https://pimterry.github.io/loglevel/demo/index.html
|
||||
|
||||
Loglevel is a barebones reliable everyday logging library. It does not do fancy things, it does not let you reconfigure appenders or add complex log filtering rules or boil tea (more's the pity), but it does have the all core functionality that you actually use:
|
||||
|
||||
## Features
|
||||
|
||||
### Simple
|
||||
|
||||
* Log things at a given level (trace/debug/info/warn/error) to the `console` object (as seen in all modern browsers & node.js).
|
||||
* Filter logging by level (all the above or 'silent'), so you can disable all but error logging in production, and then run `log.setLevel("trace")` in your console to turn it all back on for a furious debugging session.
|
||||
* Single file, no dependencies, weighs in at 1.4 KB minified and gzipped.
|
||||
|
||||
### Effective
|
||||
|
||||
* Log methods gracefully fall back to simpler console logging methods if more specific ones aren't available: so calls to `log.debug()` go to `console.debug()` if possible, or `console.log()` if not.
|
||||
* Logging calls still succeed even if there's no `console` object at all, so your site doesn't break when people visit with old browsers that don't support the `console` object (here's looking at you, IE) and similar.
|
||||
* This then comes together giving a consistent reliable API that works in every JavaScript environment with a console available, and never breaks anything anywhere else.
|
||||
|
||||
### Convenient
|
||||
|
||||
* Log output keeps line numbers: most JS logging frameworks call `console.log` methods through wrapper functions, clobbering your stacktrace and making the extra info many browsers provide useless. We'll have none of that thanks.
|
||||
* It works with all the standard JavaScript loading systems out of the box (CommonJS, AMD, or just as a global).
|
||||
* Logging is filtered to "warn" level by default, to keep your live site clean in normal usage (or you can trivially re-enable everything with an initial `log.enableAll()` call).
|
||||
* Magically handles situations where console logging is not initially available (IE8/9), and automatically enables logging as soon as it does become available (when developer console is opened).
|
||||
* TypeScript type definitions included, so no need for extra `@types` packages.
|
||||
* Extensible, to add other log redirection, filtering, or formatting functionality, while keeping all the above (except you will clobber your stacktrace, see [“Plugins”](#plugins) below).
|
||||
|
||||
## Downloading loglevel
|
||||
|
||||
If you're using NPM, you can just run `npm install loglevel`.
|
||||
|
||||
Alternatively, loglevel is also available via [Bower](https://github.com/bower/bower) (`bower install loglevel`), as a [Webjar](http://www.webjars.org/), or an [Atmosphere package](https://atmospherejs.com/spacejamio/loglevel) (for Meteor)
|
||||
|
||||
Alternatively if you just want to grab the file yourself, you can download either the current stable [production version][min] or the [development version][max] directly, or reference it remotely on unpkg at [`https://unpkg.com/loglevel/dist/loglevel.min.js`][cdn] (this will redirect to a latest version, use the resulting redirected URL if you want to pin that version).
|
||||
|
||||
Finally, if you want to tweak loglevel to your own needs or you immediately need the cutting-edge version, clone this repo and see [Developing & Contributing](#developing--contributing) below for build instructions.
|
||||
|
||||
[min]: https://raw.github.com/pimterry/loglevel/master/dist/loglevel.min.js
|
||||
[max]: https://raw.github.com/pimterry/loglevel/master/dist/loglevel.js
|
||||
[cdn]: https://unpkg.com/loglevel/dist/loglevel.min.js
|
||||
|
||||
## Setting it up
|
||||
|
||||
loglevel supports AMD (e.g. RequireJS), CommonJS (e.g. Node.js) and direct usage (e.g. loading globally with a `<script>` tag) loading methods. You should be able to do nearly anything, and then skip to the next section anyway and have it work. Just in case, though, here's some specific examples that definitely do the right thing:
|
||||
|
||||
### CommonsJS (e.g. Node)
|
||||
|
||||
```javascript
|
||||
var log = require('loglevel');
|
||||
log.warn("unreasonably simple");
|
||||
```
|
||||
|
||||
### AMD (e.g. RequireJS)
|
||||
|
||||
```javascript
|
||||
define(['loglevel'], function(log) {
|
||||
log.warn("dangerously convenient");
|
||||
});
|
||||
```
|
||||
|
||||
### Directly in your web page
|
||||
|
||||
```html
|
||||
<script src="loglevel.min.js"></script>
|
||||
<script>
|
||||
log.warn("too easy");
|
||||
</script>
|
||||
```
|
||||
|
||||
### As an ES6 module
|
||||
|
||||
loglevel is written as a UMD module, with a single object exported. Unfortunately, ES6 module loaders & transpilers don't all handle this the same way. Some will treat the object as the default export, while others use it as the root exported object. In addition, loglevel includes a `default` property on the root object, designed to help handle this difference. Nonetheless, there are two possible syntaxes that might work for you:
|
||||
|
||||
For most tools, using the default import is the most convenient and flexible option:
|
||||
|
||||
```javascript
|
||||
import log from 'loglevel';
|
||||
log.warn("module-tastic");
|
||||
```
|
||||
|
||||
For some tools though, it might better to wildcard import the whole object:
|
||||
|
||||
```javascript
|
||||
import * as log from 'loglevel';
|
||||
log.warn("module-tastic");
|
||||
```
|
||||
|
||||
There's no major difference, unless you're using TypeScript & building a loglevel plugin (in that case, see <https://github.com/pimterry/loglevel/issues/149>). In general though, just use whichever suits your environment, and everything should work out fine.
|
||||
|
||||
### With noConflict()
|
||||
|
||||
If you're using another JavaScript library that exposes a `log` global, you can run into conflicts with loglevel. Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded onto the page. This resets the `log` global to its value before loglevel was loaded (typically `undefined`), and returns the loglevel object, which you can then bind to another name yourself.
|
||||
|
||||
For example:
|
||||
|
||||
```html
|
||||
<script src="loglevel.min.js"></script>
|
||||
<script>
|
||||
var logging = log.noConflict();
|
||||
|
||||
logging.warn("still pretty easy");
|
||||
</script>
|
||||
```
|
||||
|
||||
### TypeScript
|
||||
|
||||
loglevel includes its own type definitions, assuming you're using a modern module environment (e.g. Node.JS, webpack, etc), you should be able to use the ES6 syntax above, and everything will work immediately. If not, file a bug!
|
||||
|
||||
If you really want to use LogLevel as a global however, but from TypeScript, you'll need to declare it as such first. To do that:
|
||||
|
||||
* Create a `loglevel.d.ts` file
|
||||
* Ensure that file is included in your build (e.g. add it to `include` in your tsconfig, pass it on the command line, or use `///<reference path="./loglevel.d.ts" />`)
|
||||
* In that file, add:
|
||||
|
||||
```typescript
|
||||
import * as log from 'loglevel';
|
||||
export as namespace log;
|
||||
export = log;
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
### Methods
|
||||
|
||||
The loglevel API is extremely minimal. All methods are available on the root loglevel object, which we suggest you name `log` (this is the default if you import it globally, and is what's set up in the above examples). The API consists of:
|
||||
|
||||
#### Logging Methods
|
||||
|
||||
5 actual logging methods, ordered and available as:
|
||||
|
||||
* `log.trace(msg)`
|
||||
* `log.debug(msg)`
|
||||
* `log.info(msg)`
|
||||
* `log.warn(msg)`
|
||||
* `log.error(msg)`
|
||||
|
||||
`log.log(msg)` is also available, as an alias for `log.debug(msg)`, to improve compatibility with `console`, and make migration easier.
|
||||
|
||||
Exact output formatting of these will depend on the console available in the current context of your application. For example, many environments will include a full stack trace with all `trace()` calls, and icons or similar to highlight other calls.
|
||||
|
||||
These methods should never fail in any environment, even if no `console` object is currently available, and should always fall back to an available log method even if the specific method called (e.g. `warn`) isn't available.
|
||||
|
||||
Be aware that this means that these methods won't always produce exactly the output you expect in every environment; loglevel only guarantees that these methods will never explode on you, and that it will call the most relevant method it can find, with your argument. For example, `log.trace(msg)` in Firefox before version 64 prints the stacktrace by itself, and doesn't include your message (see [#84](https://github.com/pimterry/loglevel/issues/84)).
|
||||
|
||||
#### `log.setLevel(level, [persist])`
|
||||
|
||||
This disables all logging below the given level, so that after a `log.setLevel("warn")` call `log.warn("something")` or `log.error("something")` will output messages, but `log.info("something")` will not.
|
||||
|
||||
This can take either a log level name or `'silent'` (which disables everything) in one of a few forms:
|
||||
|
||||
* As a log level from the internal levels list, e.g. `log.levels.SILENT` ← _for type safety_
|
||||
* As a string, like `'error'` (case-insensitive) ← _for a reasonable practical balance_
|
||||
* As a numeric index from `0` (trace) to `5` (silent) ← _deliciously terse, and more easily programmable (...although, why?)_
|
||||
|
||||
Where possible, the log level will be persisted. LocalStorage will be used if available, falling back to cookies if not. If neither is available in the current environment (e.g. in Node), or if you pass `false` as the optional 'persist' second argument, persistence will be skipped.
|
||||
|
||||
If `log.setLevel()` is called when a `console` object is not available (in IE 8 or 9 before the developer tools have been opened, for example) logging will remain silent until the console becomes available, and then begin logging at the requested level.
|
||||
|
||||
#### `log.setDefaultLevel(level)`
|
||||
|
||||
This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when initializing modules or scripts; if a developer or user has previously called `setLevel()`, this won’t alter their settings. For example, your application might use `setDefaultLevel("error")` set the log level to `error` in a production environment, but when debugging an issue, you might call `setLevel("trace")` on the console to see all the logs. If that `error` setting was set using `setDefaultLevel()`, it will still stay as `trace` on subsequent page loads and refreshes instead of resetting to `error`.
|
||||
|
||||
The `level` argument takes the same values that you might pass to `setLevel()`. Levels set using `setDefaultLevel()` never persist to subsequent page loads.
|
||||
|
||||
#### `log.resetLevel()`
|
||||
|
||||
This resets the current log level to the logger's default level (if no explicit default was set, then it resets it to the root logger's level, or to `WARN`) and clears the persisted level if one was previously persisted.
|
||||
|
||||
#### `log.enableAll()` and `log.disableAll()`
|
||||
|
||||
These enable or disable all log messages, and are equivalent to `log.setLevel("trace")` and `log.setLevel("silent")`, respectively.
|
||||
|
||||
#### `log.getLevel()`
|
||||
|
||||
Returns the current logging level, as a number from `0` (trace) to `5` (silent)
|
||||
|
||||
It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin development, and partly to let you optimize logging code as below, where debug data is only generated if the level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling on your code and you have hard numbers telling you that your log data generation is a real performance problem.
|
||||
|
||||
```javascript
|
||||
if (log.getLevel() <= log.levels.DEBUG) {
|
||||
var logData = runExpensiveDataGeneration();
|
||||
log.debug(logData);
|
||||
}
|
||||
```
|
||||
|
||||
This notably isn't the right solution to avoid the cost of string concatenation in your logging. Firstly, it's very unlikely that string concatenation in your logging is really an important performance problem. Even if you do genuinely have hard metrics showing that it is, though, the better solution that wrapping your log statements in this is to use multiple arguments, as below. The underlying console API will automatically concatenate these for you if logging is enabled, and if it isn't then all log methods are no-ops, and no concatenation will be done at all.
|
||||
|
||||
```javascript
|
||||
// Prints 'My concatenated log message'
|
||||
log.debug("My", "concatenated", "log message");
|
||||
```
|
||||
|
||||
#### `log.getLogger(loggerName)`
|
||||
|
||||
This gets you a new logger object that works exactly like the root `log` object, but can have its level and logging methods set independently. All loggers must have a name (which is a non-empty string, or a [Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)). Calling `getLogger()` multiple times with the same name will return an identical logger object.
|
||||
|
||||
In large applications, it can be incredibly useful to turn logging on and off for particular modules as you are working with them. Using the `getLogger()` method lets you create a separate logger for each part of your application with its own logging level.
|
||||
|
||||
Likewise, for small, independent modules, using a named logger instead of the default root logger allows developers using your module to selectively turn on deep, trace-level logging when trying to debug problems, while logging only errors or silencing logging altogether under normal circumstances.
|
||||
|
||||
Example usage _(using CommonJS modules, but you could do the same with any module system):_
|
||||
|
||||
```javascript
|
||||
// In module-one.js:
|
||||
var log = require("loglevel").getLogger("module-one");
|
||||
function doSomethingAmazing() {
|
||||
log.debug("Amazing message from module one.");
|
||||
}
|
||||
|
||||
// In module-two.js:
|
||||
var log = require("loglevel").getLogger("module-two");
|
||||
function doSomethingSpecial() {
|
||||
log.debug("Special message from module two.");
|
||||
}
|
||||
|
||||
// In your main application module:
|
||||
var log = require("loglevel");
|
||||
var moduleOne = require("module-one");
|
||||
var moduleTwo = require("module-two");
|
||||
log.getLogger("module-two").setLevel("TRACE");
|
||||
|
||||
moduleOne.doSomethingAmazing();
|
||||
moduleTwo.doSomethingSpecial();
|
||||
// logs "Special message from module two."
|
||||
// (but nothing from module one.)
|
||||
```
|
||||
|
||||
Loggers returned by `getLogger()` support all the same properties and methods as the default root logger, excepting `noConflict()` and the `getLogger()` method itself.
|
||||
|
||||
Like the root logger, other loggers can have their logging level saved. If a logger’s level has not been saved, it will inherit the root logger’s level when it is first created. If the root logger’s level changes later, the new level will not affect other loggers that have already been created. Loggers with Symbol names (rather than string names) will always be considered unique instances, and will never have their logging level saved or restored.
|
||||
|
||||
Likewise, loggers inherit the root logger’s `methodFactory`. After creation, each logger can have its `methodFactory` independently set. See the _plugins_ section below for more about `methodFactory`.
|
||||
|
||||
#### `log.getLoggers()`
|
||||
|
||||
This will return the dictionary of all loggers created with `getLogger()`, keyed by their names.
|
||||
|
||||
#### `log.rebuild()`
|
||||
|
||||
Ensure the various logging methods (`log.info()`, `log.warn()`, etc.) behave as expected given the currently set logging level and `methodFactory`. It will also rebuild all child loggers of the logger this was called on.
|
||||
|
||||
This is mostly useful for plugin development. When you call `log.setLevel()` or `log.setDefaultLevel()`, the logger is rebuilt automatically. However, if you change the logger’s `methodFactory`, you should use this to rebuild all the logging methods with your new factory.
|
||||
|
||||
It is also useful if you change the level of the root logger and want it to affect child loggers that you’ve already created (and have not called `someChildLogger.setLevel()` or `someChildLogger.setDefaultLevel()` on). For example:
|
||||
|
||||
```js
|
||||
var childLogger1 = log.getLogger("child1");
|
||||
childLogger1.getLevel(); // WARN (inherited from the root logger)
|
||||
|
||||
var childLogger2 = log.getLogger("child2");
|
||||
childLogger2.setDefaultLevel("TRACE");
|
||||
childLogger2.getLevel(); // TRACE
|
||||
|
||||
log.setLevel("ERROR");
|
||||
|
||||
// At this point, the child loggers have not changed:
|
||||
childLogger1.getLevel(); // WARN
|
||||
childLogger2.getLevel(); // TRACE
|
||||
|
||||
// To update them:
|
||||
log.rebuild();
|
||||
childLogger1.getLevel(); // ERROR (still inheriting from root logger)
|
||||
childLogger2.getLevel(); // TRACE (no longer inheriting because `.setDefaultLevel() was called`)
|
||||
```
|
||||
|
||||
## Plugins
|
||||
|
||||
### Existing plugins
|
||||
|
||||
[loglevel-plugin-prefix](https://github.com/kutuluk/loglevel-plugin-prefix) - plugin for loglevel message prefixing.
|
||||
|
||||
[loglevel-plugin-remote](https://github.com/kutuluk/loglevel-plugin-remote) - plugin for sending loglevel messages to a remote log server.
|
||||
|
||||
[loglevel-serverSend](https://github.com/artemyarulin/loglevel-serverSend) - Forward your log messages to a remote server.
|
||||
|
||||
[loglevel-debug](https://github.com/vectrlabs/loglevel-debug) - Control logging from a DEBUG environmental variable (similar to the classic [Debug](https://github.com/visionmedia/debug) module).
|
||||
|
||||
### Writing plugins
|
||||
|
||||
Loglevel provides a simple, reliable, minimal base for console logging that works everywhere. This means it doesn't include lots of fancy functionality that might be useful in some cases, such as log formatting and redirection (e.g. also sending log messages to a server over AJAX)
|
||||
|
||||
Including that would increase the size and complexity of the library, but more importantly would remove stacktrace information. Currently log methods are either disabled, or enabled with directly bound versions of the `console.log` methods (where possible). This means your browser shows the log message as coming from your code at the call to `log.info("message!")` not from within loglevel, since it really calls the bound console method directly, without indirection. The indirection required to dynamically format, further filter, or redirect log messages would stop this.
|
||||
|
||||
There's clearly enough enthusiasm for this even at that cost that loglevel now includes a plugin API. To use it, redefine `log.methodFactory(methodName, logLevel, loggerName)` with a function of your own. This will be called for each enabled method each time the level is set (including initially), and should return a function to be used for the given log method `methodName`, at the given _configured_ (not actual) level `logLevel`, for a logger with the given name `loggerName`. If you'd like to retain all the reliability and features of loglevel, we recommended that you wrap the initially provided value of `log.methodFactory`.
|
||||
|
||||
For example, a plugin to prefix all log messages with "Newsflash: " would look like:
|
||||
|
||||
```javascript
|
||||
var originalFactory = log.methodFactory;
|
||||
log.methodFactory = function (methodName, logLevel, loggerName) {
|
||||
var rawMethod = originalFactory(methodName, logLevel, loggerName);
|
||||
|
||||
return function (message) {
|
||||
rawMethod("Newsflash: " + message);
|
||||
};
|
||||
};
|
||||
log.rebuild(); // Be sure to call the rebuild method in order to apply plugin.
|
||||
```
|
||||
|
||||
*(The above supports only a single string `log.warn("...")` argument for clarity, but it's easy to extend to a [fuller variadic version](http://jsbin.com/xehoye/edit?html,console).)*
|
||||
|
||||
If you develop and release a plugin, please get in contact! I'd be happy to reference it here for future users. Some consistency is helpful; naming your plugin 'loglevel-PLUGINNAME' (e.g. loglevel-newsflash) is preferred, as is giving it the 'loglevel-plugin' keyword in your `package.json`.
|
||||
|
||||
## Developing & Contributing
|
||||
|
||||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
|
||||
|
||||
Builds can be run with npm: run `npm run dist` to build a distributable version of the project (in `dist/`), or `npm test` to just run the tests and linting. During development you can run `npm run watch` and it will monitor source files, and rerun the tests and linting as appropriate when they're changed.
|
||||
|
||||
_Also, please don't manually edit files in the `dist/` subdirectory as they are generated via Grunt. You'll find source code in the `lib/` subdirectory!_
|
||||
|
||||
#### Release process
|
||||
|
||||
To do a release of loglevel:
|
||||
|
||||
* Update the version number in `package.json` and `bower.json`.
|
||||
* Run `npm run dist` to build a distributable version in `dist/`.
|
||||
* Update the release history in this file (below).
|
||||
* Commit the built code, tagging it with the version number and a brief message about the release.
|
||||
* Push to Github.
|
||||
* Run `npm publish .` to publish to NPM.
|
||||
|
||||
## Release History
|
||||
|
||||
v0.1.0 - First working release with apparent compatibility with everything tested
|
||||
|
||||
v0.2.0 - Updated release with various tweaks and polish and real proper documentation attached
|
||||
|
||||
v0.3.0 - Some bugfixes ([#12](https://github.com/pimterry/loglevel/issues/12), [#14](https://github.com/pimterry/loglevel/issues/14)), cookie-based log level persistence, doc tweaks, support for Bower and JamJS
|
||||
|
||||
v0.3.1 - Fixed incorrect text in release build banner, various other minor tweaks
|
||||
|
||||
v0.4.0 - Use LocalStorage for level persistence if available, compatibility improvements for IE, improved error messages, multi-environment tests
|
||||
|
||||
v0.5.0 - Fix for Modernizr+IE8 issues, improved setLevel error handling, support for auto-activation of desired logging when console eventually turns up in IE8
|
||||
|
||||
v0.6.0 - Handle logging in Safari private browsing mode ([#33](https://github.com/pimterry/loglevel/issues/33)), fix `TRACE` level persistence bug ([#35](https://github.com/pimterry/loglevel/issues/35)), plus various minor tweaks
|
||||
|
||||
v1.0.0 - Official stable release! Fixed a bug with localStorage in Android webviews, improved CommonJS detection, and added `noConflict()`.
|
||||
|
||||
v1.1.0 - Added support for including loglevel with preprocessing and `.apply()` ([#50](https://github.com/pimterry/loglevel/issues/50)), and fixed QUnit dep version which made tests potentially unstable.
|
||||
|
||||
v1.2.0 - New plugin API! Plus various bits of refactoring and tidy up, nicely simplifying things and trimming the size down.
|
||||
|
||||
v1.3.0 - Make persistence optional in `setLevel()`, plus lots of documentation updates and other small tweaks
|
||||
|
||||
v1.3.1 - With the new optional persistence, stop unnecessarily persisting the initially set default level (`WARN`)
|
||||
|
||||
v1.4.0 - Add `getLevel()`, `setDefaultLevel()` and `getLogger()` functionality for more fine-grained log level control
|
||||
|
||||
v1.4.1 - Reorder UMD ([#92](https://github.com/pimterry/loglevel/issues/92)) to improve bundling tool compatibility
|
||||
|
||||
v1.5.0 - Fix `log.debug` ([#111](https://github.com/pimterry/loglevel/issues/111)) after V8 changes deprecating console.debug, check for `window` upfront ([#104](https://github.com/pimterry/loglevel/issues/104)), and add `.log` alias for `.debug` ([#64](https://github.com/pimterry/loglevel/issues/64))
|
||||
|
||||
v1.5.1 - Fix bug ([#112](https://github.com/pimterry/loglevel/issues/112)) in level-persistence cookie fallback, which failed if it wasn't the first cookie present
|
||||
|
||||
v1.6.0 - Add a name property to loggers and add `log.getLoggers()` ([#114](https://github.com/pimterry/loglevel/issues/114)), and recommend unpkg as CDN instead of CDNJS.
|
||||
|
||||
v1.6.1 - Various small documentation & test updates
|
||||
|
||||
v1.6.2 - Include TypeScript type definitions in the package itself
|
||||
|
||||
v1.6.3 - Avoid TypeScript type conflicts with other global `log` types (e.g. `core-js`)
|
||||
|
||||
v1.6.4 - Ensure `package.json`'s `"main"` is a fully qualified path, to fix webpack issues
|
||||
|
||||
v1.6.5 - Ensure the provided message is included when calling `trace()` in IE11
|
||||
|
||||
v1.6.6 - Fix bugs in v1.6.5, which caused issues in node.js & IE < 9
|
||||
|
||||
v1.6.7 - Fix a bug in environments with `window` defined but no `window.navigator`
|
||||
|
||||
v1.6.8 - Update TypeScript type definitions to include `log.log()`.
|
||||
|
||||
v1.7.0 - Add support for Symbol-named loggers, and a `.default` property to help with ES6 module usage.
|
||||
|
||||
v1.7.1 - Update TypeScript types to support Symbol-named loggers.
|
||||
|
||||
v1.8.0 - Add `resetLevel()` method to clear persisted levels & reset to defaults
|
||||
|
||||
v1.8.1 - Fix incorrect type definitions for `MethodFactory`
|
||||
|
||||
v1.9.0 - Added `rebuild()` method, overhaul dev & test setup, and fix some bugs (notably around cookies) en route
|
||||
|
||||
v1.9.1 - Fix a bug introduced in 1.9.0 that broke `setLevel()` in some ESM-focused runtime environments
|
||||
|
||||
v1.9.2 - Remove unnecessarily extra test & CI files from deployed package
|
||||
|
||||
## `loglevel` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of `loglevel` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-loglevel?utm_source=npm-loglevel&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2013 Tim Perry
|
||||
Licensed under the MIT license. See [`LICENSE-MIT`](./LICENSE-MIT) for full license text.
|
||||
1
node_modules/loglevel/_config.yml
generated
vendored
Normal file
1
node_modules/loglevel/_config.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-minimal
|
||||
11
node_modules/loglevel/bower.json
generated
vendored
Normal file
11
node_modules/loglevel/bower.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "loglevel",
|
||||
"version": "1.9.2",
|
||||
"main": "dist/loglevel.min.js",
|
||||
"dependencies": {},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"components"
|
||||
]
|
||||
}
|
||||
139
node_modules/loglevel/demo/index.html
generated
vendored
Normal file
139
node_modules/loglevel/demo/index.html
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>loglevel Demo</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="A demo to show the features of loglevel."
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@48,600,0,0"
|
||||
/>
|
||||
</head>
|
||||
<main>
|
||||
<h1>loglevel Demo</h1>
|
||||
<form id="LogForm" class="code-container">
|
||||
<code>
|
||||
log.
|
||||
<select name="logLevel" aria-label="Log type" required>
|
||||
<option value="trace">trace</option>
|
||||
<option value="debug">debug</option>
|
||||
<option value="info">info</option>
|
||||
<option value="warn">warn</option>
|
||||
<option value="error">error</option>
|
||||
</select>
|
||||
("
|
||||
<input
|
||||
name="debugMessage"
|
||||
type="text"
|
||||
placeholder="Log text"
|
||||
aria-label="Log text"
|
||||
required
|
||||
/>
|
||||
")
|
||||
</code>
|
||||
<button type="submit">Run</button>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Choose your level of logging and enter some text to output it to the console using logLevel.
|
||||
<a href="https://github.com/pimterry/loglevel#logging-methods">Documentation for logging methods.</a>
|
||||
</details>
|
||||
</form>
|
||||
<form id="SetLevel" class="code-container">
|
||||
<code>
|
||||
log.setLevel("
|
||||
<select name="level" aria-label="Log type" required>
|
||||
<option value="0">trace</option>
|
||||
<option value="1">debug</option>
|
||||
<option value="2">info</option>
|
||||
<option value="3">warn</option>
|
||||
<option value="4">error</option>
|
||||
<option value="5">silent</option>
|
||||
</select>
|
||||
",
|
||||
<select name="persist" aria-label="Log type" required>
|
||||
<option value="true">true</option>
|
||||
<option value="false">false</option>
|
||||
</select>
|
||||
)
|
||||
</code>
|
||||
<button type="submit">Run</button>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Disable all logging below the given level.
|
||||
<a href="https://github.com/pimterry/loglevel#logsetlevellevel-persist">Documentation for setLevel().</a>
|
||||
</details>
|
||||
</form>
|
||||
<form id="SetDefaultLevel" class="code-container">
|
||||
<code>
|
||||
log.setDefaultLevel("
|
||||
<select name="level" aria-label="Log type" required>
|
||||
<option value="0">trace</option>
|
||||
<option value="1">debug</option>
|
||||
<option value="2">info</option>
|
||||
<option value="3">warn</option>
|
||||
<option value="4">error</option>
|
||||
<option value="5">silent</option>
|
||||
</select>
|
||||
")
|
||||
</code>
|
||||
<button type="submit">Run</button>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Select a level and run to set the default logging level.
|
||||
<a href="https://github.com/pimterry/loglevel#logsetdefaultlevellevel">Documentation for setDefaultLevel().</a>
|
||||
</details>
|
||||
</form>
|
||||
<div class="code-container">
|
||||
<code>
|
||||
log.resetLevel()
|
||||
</code>
|
||||
<button id="ResetLevelButton" type="button">Run</button>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Reset the current logging level to default.
|
||||
<a href="https://github.com/pimterry/loglevel#logresetlevel">Documentation for resetLevel().</a>
|
||||
</details>
|
||||
</div>
|
||||
<div class="code-container">
|
||||
<code>
|
||||
log.enableAll()
|
||||
</code>
|
||||
<button id="EnableAllButton" type="button">Run</button>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Enables all logs - equivalent of <code>setLevel('trace')</code>.
|
||||
<a href="https://github.com/pimterry/loglevel##logenableall-and-logdisableall">Documentation for enableAll().</a>
|
||||
</details>
|
||||
</div>
|
||||
<div class="code-container">
|
||||
<code>
|
||||
log.disableAll()
|
||||
</code>
|
||||
<button id="DisableAllButton" type="button">Run</button>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Disables all logs - equivalent of <code>setLevel('silent')</code>.
|
||||
<a href="https://github.com/pimterry/loglevel##logenableall-and-logdisableall">Documentation for disableAll().</a>
|
||||
</details>
|
||||
</div>
|
||||
<h2>Log State</h2>
|
||||
<div id="LogState" class="code-container">
|
||||
<label>
|
||||
Current log level
|
||||
<input name="currentLevel" aria-label="Current log level" readonly>
|
||||
</label>
|
||||
<details>
|
||||
<summary>More information...</summary>
|
||||
Uses the <code>getLevel()</code> method to display the current log level.
|
||||
<a href="https://github.com/pimterry/loglevel##logenableall-and-logdisableall">Documentation for disableAll().</a>
|
||||
</details>
|
||||
</div>
|
||||
</main>
|
||||
<script src="../dist/loglevel.js"></script>
|
||||
<script src="script.js"></script>
|
||||
</html>
|
||||
86
node_modules/loglevel/demo/script.js
generated
vendored
Normal file
86
node_modules/loglevel/demo/script.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
log.setDefaultLevel(log.levels.TRACE, false);
|
||||
|
||||
const demoForm = document.getElementById('LogForm');
|
||||
const setLevelForm = document.getElementById('SetLevel');
|
||||
const setDefaultLevelForm = document.getElementById('SetDefaultLevel');
|
||||
const resetLevelButton = document.getElementById('ResetLevelButton');
|
||||
const enableAllButton = document.getElementById('EnableAllButton');
|
||||
const disableAllButton = document.getElementById('DisableAllButton');
|
||||
|
||||
if (demoForm) {
|
||||
demoForm.addEventListener('submit', onSubmitDemoForm);
|
||||
}
|
||||
|
||||
if (setLevelForm) {
|
||||
setLevelForm.addEventListener('submit', onSubmitSetLevelForm);
|
||||
}
|
||||
|
||||
if (setDefaultLevelForm) {
|
||||
setDefaultLevelForm.addEventListener('submit', onSubmitSetDefaultLevelForm);
|
||||
}
|
||||
|
||||
if (resetLevelButton) {
|
||||
resetLevelButton.addEventListener('click', () => {
|
||||
log.resetLevel();
|
||||
updateLogStateForm();
|
||||
});
|
||||
}
|
||||
|
||||
if (enableAllButton) {
|
||||
enableAllButton.addEventListener('click', () => {
|
||||
log.enableAll();
|
||||
updateLogStateForm();
|
||||
});
|
||||
}
|
||||
|
||||
if (disableAllButton) {
|
||||
disableAllButton.addEventListener('click', () => {
|
||||
log.disableAll();
|
||||
updateLogStateForm();
|
||||
});
|
||||
}
|
||||
|
||||
updateLogStateForm();
|
||||
});
|
||||
|
||||
function onSubmitDemoForm(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const form = event.currentTarget;
|
||||
const formData = new FormData(form)
|
||||
const debugMessage = formData.get('debugMessage');
|
||||
const logLevel = formData.get('logLevel');
|
||||
|
||||
if (debugMessage && logLevel) {
|
||||
log[logLevel](debugMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmitSetLevelForm(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const form = event.currentTarget;
|
||||
const formData = new FormData(form)
|
||||
log.setLevel(parseInt(formData.get('level')), formData.get('persist') === 'true');
|
||||
updateLogStateForm();
|
||||
}
|
||||
|
||||
function onSubmitSetDefaultLevelForm(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const form = event.currentTarget;
|
||||
const formData = new FormData(form)
|
||||
log.setDefaultLevel(parseInt(formData.get('level')));
|
||||
updateLogStateForm();
|
||||
}
|
||||
|
||||
function updateLogStateForm() {
|
||||
const logState = document.getElementById('LogState');
|
||||
|
||||
if (logState) {
|
||||
const currentLevel = logState.querySelector('input[name="currentLevel"]');
|
||||
const logLevel = log.getLevel();
|
||||
currentLevel.value = Object.keys(log.levels).find(key => log.levels[key] === logLevel);
|
||||
}
|
||||
}
|
||||
107
node_modules/loglevel/demo/styles.css
generated
vendored
Normal file
107
node_modules/loglevel/demo/styles.css
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
font-family:system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
color: #161230;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 18px;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
form {
|
||||
}
|
||||
|
||||
label {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
button {
|
||||
/* flex-grow: 1; */
|
||||
font-size: 1rem;
|
||||
padding: 0.25rem;
|
||||
border: 1px solid;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
align-self: center;
|
||||
padding: 0.5rem 1.5rem;
|
||||
background-color: #161230;
|
||||
color: #fafafa;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
code,
|
||||
code > input,
|
||||
code > select {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
code {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
code input,
|
||||
code select {
|
||||
border-color: #a9b7c9;
|
||||
}
|
||||
|
||||
code button {
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
||||
details {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
summary {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
details code {
|
||||
display: inline-block;
|
||||
font-size: 1.1rem;
|
||||
margin-left: 0.2rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.code-container {
|
||||
width: 80vw;
|
||||
max-width: 800px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
border: 1px solid;
|
||||
border-radius: 4px;
|
||||
background-color: #eaf3ff;
|
||||
padding: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
352
node_modules/loglevel/dist/loglevel.js
generated
vendored
Normal file
352
node_modules/loglevel/dist/loglevel.js
generated
vendored
Normal file
@@ -0,0 +1,352 @@
|
||||
/*! loglevel - v1.9.2 - https://github.com/pimterry/loglevel - (c) 2024 Tim Perry - licensed MIT */
|
||||
(function (root, definition) {
|
||||
"use strict";
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(definition);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
module.exports = definition();
|
||||
} else {
|
||||
root.log = definition();
|
||||
}
|
||||
}(this, function () {
|
||||
"use strict";
|
||||
|
||||
// Slightly dubious tricks to cut down minimized file size
|
||||
var noop = function() {};
|
||||
var undefinedType = "undefined";
|
||||
var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
|
||||
/Trident\/|MSIE /.test(window.navigator.userAgent)
|
||||
);
|
||||
|
||||
var logMethods = [
|
||||
"trace",
|
||||
"debug",
|
||||
"info",
|
||||
"warn",
|
||||
"error"
|
||||
];
|
||||
|
||||
var _loggersByName = {};
|
||||
var defaultLogger = null;
|
||||
|
||||
// Cross-browser bind equivalent that works at least back to IE6
|
||||
function bindMethod(obj, methodName) {
|
||||
var method = obj[methodName];
|
||||
if (typeof method.bind === 'function') {
|
||||
return method.bind(obj);
|
||||
} else {
|
||||
try {
|
||||
return Function.prototype.bind.call(method, obj);
|
||||
} catch (e) {
|
||||
// Missing bind shim or IE8 + Modernizr, fallback to wrapping
|
||||
return function() {
|
||||
return Function.prototype.apply.apply(method, [obj, arguments]);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trace() doesn't print the message in IE, so for that case we need to wrap it
|
||||
function traceForIE() {
|
||||
if (console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
// In old IE, native console methods themselves don't have apply().
|
||||
Function.prototype.apply.apply(console.log, [console, arguments]);
|
||||
}
|
||||
}
|
||||
if (console.trace) console.trace();
|
||||
}
|
||||
|
||||
// Build the best logging method possible for this env
|
||||
// Wherever possible we want to bind, not wrap, to preserve stack traces
|
||||
function realMethod(methodName) {
|
||||
if (methodName === 'debug') {
|
||||
methodName = 'log';
|
||||
}
|
||||
|
||||
if (typeof console === undefinedType) {
|
||||
return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
|
||||
} else if (methodName === 'trace' && isIE) {
|
||||
return traceForIE;
|
||||
} else if (console[methodName] !== undefined) {
|
||||
return bindMethod(console, methodName);
|
||||
} else if (console.log !== undefined) {
|
||||
return bindMethod(console, 'log');
|
||||
} else {
|
||||
return noop;
|
||||
}
|
||||
}
|
||||
|
||||
// These private functions always need `this` to be set properly
|
||||
|
||||
function replaceLoggingMethods() {
|
||||
/*jshint validthis:true */
|
||||
var level = this.getLevel();
|
||||
|
||||
// Replace the actual methods.
|
||||
for (var i = 0; i < logMethods.length; i++) {
|
||||
var methodName = logMethods[i];
|
||||
this[methodName] = (i < level) ?
|
||||
noop :
|
||||
this.methodFactory(methodName, level, this.name);
|
||||
}
|
||||
|
||||
// Define log.log as an alias for log.debug
|
||||
this.log = this.debug;
|
||||
|
||||
// Return any important warnings.
|
||||
if (typeof console === undefinedType && level < this.levels.SILENT) {
|
||||
return "No console available for logging";
|
||||
}
|
||||
}
|
||||
|
||||
// In old IE versions, the console isn't present until you first open it.
|
||||
// We build realMethod() replacements here that regenerate logging methods
|
||||
function enableLoggingWhenConsoleArrives(methodName) {
|
||||
return function () {
|
||||
if (typeof console !== undefinedType) {
|
||||
replaceLoggingMethods.call(this);
|
||||
this[methodName].apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// By default, we use closely bound real methods wherever possible, and
|
||||
// otherwise we wait for a console to appear, and then try again.
|
||||
function defaultMethodFactory(methodName, _level, _loggerName) {
|
||||
/*jshint validthis:true */
|
||||
return realMethod(methodName) ||
|
||||
enableLoggingWhenConsoleArrives.apply(this, arguments);
|
||||
}
|
||||
|
||||
function Logger(name, factory) {
|
||||
// Private instance variables.
|
||||
var self = this;
|
||||
/**
|
||||
* The level inherited from a parent logger (or a global default). We
|
||||
* cache this here rather than delegating to the parent so that it stays
|
||||
* in sync with the actual logging methods that we have installed (the
|
||||
* parent could change levels but we might not have rebuilt the loggers
|
||||
* in this child yet).
|
||||
* @type {number}
|
||||
*/
|
||||
var inheritedLevel;
|
||||
/**
|
||||
* The default level for this logger, if any. If set, this overrides
|
||||
* `inheritedLevel`.
|
||||
* @type {number|null}
|
||||
*/
|
||||
var defaultLevel;
|
||||
/**
|
||||
* A user-specific level for this logger. If set, this overrides
|
||||
* `defaultLevel`.
|
||||
* @type {number|null}
|
||||
*/
|
||||
var userLevel;
|
||||
|
||||
var storageKey = "loglevel";
|
||||
if (typeof name === "string") {
|
||||
storageKey += ":" + name;
|
||||
} else if (typeof name === "symbol") {
|
||||
storageKey = undefined;
|
||||
}
|
||||
|
||||
function persistLevelIfPossible(levelNum) {
|
||||
var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
|
||||
|
||||
if (typeof window === undefinedType || !storageKey) return;
|
||||
|
||||
// Use localStorage if available
|
||||
try {
|
||||
window.localStorage[storageKey] = levelName;
|
||||
return;
|
||||
} catch (ignore) {}
|
||||
|
||||
// Use session cookie as fallback
|
||||
try {
|
||||
window.document.cookie =
|
||||
encodeURIComponent(storageKey) + "=" + levelName + ";";
|
||||
} catch (ignore) {}
|
||||
}
|
||||
|
||||
function getPersistedLevel() {
|
||||
var storedLevel;
|
||||
|
||||
if (typeof window === undefinedType || !storageKey) return;
|
||||
|
||||
try {
|
||||
storedLevel = window.localStorage[storageKey];
|
||||
} catch (ignore) {}
|
||||
|
||||
// Fallback to cookies if local storage gives us nothing
|
||||
if (typeof storedLevel === undefinedType) {
|
||||
try {
|
||||
var cookie = window.document.cookie;
|
||||
var cookieName = encodeURIComponent(storageKey);
|
||||
var location = cookie.indexOf(cookieName + "=");
|
||||
if (location !== -1) {
|
||||
storedLevel = /^([^;]+)/.exec(
|
||||
cookie.slice(location + cookieName.length + 1)
|
||||
)[1];
|
||||
}
|
||||
} catch (ignore) {}
|
||||
}
|
||||
|
||||
// If the stored level is not valid, treat it as if nothing was stored.
|
||||
if (self.levels[storedLevel] === undefined) {
|
||||
storedLevel = undefined;
|
||||
}
|
||||
|
||||
return storedLevel;
|
||||
}
|
||||
|
||||
function clearPersistedLevel() {
|
||||
if (typeof window === undefinedType || !storageKey) return;
|
||||
|
||||
// Use localStorage if available
|
||||
try {
|
||||
window.localStorage.removeItem(storageKey);
|
||||
} catch (ignore) {}
|
||||
|
||||
// Use session cookie as fallback
|
||||
try {
|
||||
window.document.cookie =
|
||||
encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
||||
} catch (ignore) {}
|
||||
}
|
||||
|
||||
function normalizeLevel(input) {
|
||||
var level = input;
|
||||
if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
|
||||
level = self.levels[level.toUpperCase()];
|
||||
}
|
||||
if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
|
||||
return level;
|
||||
} else {
|
||||
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Public logger API - see https://github.com/pimterry/loglevel for details
|
||||
*
|
||||
*/
|
||||
|
||||
self.name = name;
|
||||
|
||||
self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
|
||||
"ERROR": 4, "SILENT": 5};
|
||||
|
||||
self.methodFactory = factory || defaultMethodFactory;
|
||||
|
||||
self.getLevel = function () {
|
||||
if (userLevel != null) {
|
||||
return userLevel;
|
||||
} else if (defaultLevel != null) {
|
||||
return defaultLevel;
|
||||
} else {
|
||||
return inheritedLevel;
|
||||
}
|
||||
};
|
||||
|
||||
self.setLevel = function (level, persist) {
|
||||
userLevel = normalizeLevel(level);
|
||||
if (persist !== false) { // defaults to true
|
||||
persistLevelIfPossible(userLevel);
|
||||
}
|
||||
|
||||
// NOTE: in v2, this should call rebuild(), which updates children.
|
||||
return replaceLoggingMethods.call(self);
|
||||
};
|
||||
|
||||
self.setDefaultLevel = function (level) {
|
||||
defaultLevel = normalizeLevel(level);
|
||||
if (!getPersistedLevel()) {
|
||||
self.setLevel(level, false);
|
||||
}
|
||||
};
|
||||
|
||||
self.resetLevel = function () {
|
||||
userLevel = null;
|
||||
clearPersistedLevel();
|
||||
replaceLoggingMethods.call(self);
|
||||
};
|
||||
|
||||
self.enableAll = function(persist) {
|
||||
self.setLevel(self.levels.TRACE, persist);
|
||||
};
|
||||
|
||||
self.disableAll = function(persist) {
|
||||
self.setLevel(self.levels.SILENT, persist);
|
||||
};
|
||||
|
||||
self.rebuild = function () {
|
||||
if (defaultLogger !== self) {
|
||||
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
||||
}
|
||||
replaceLoggingMethods.call(self);
|
||||
|
||||
if (defaultLogger === self) {
|
||||
for (var childName in _loggersByName) {
|
||||
_loggersByName[childName].rebuild();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize all the internal levels.
|
||||
inheritedLevel = normalizeLevel(
|
||||
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
||||
);
|
||||
var initialLevel = getPersistedLevel();
|
||||
if (initialLevel != null) {
|
||||
userLevel = normalizeLevel(initialLevel);
|
||||
}
|
||||
replaceLoggingMethods.call(self);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Top-level API
|
||||
*
|
||||
*/
|
||||
|
||||
defaultLogger = new Logger();
|
||||
|
||||
defaultLogger.getLogger = function getLogger(name) {
|
||||
if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
|
||||
throw new TypeError("You must supply a name when creating a logger.");
|
||||
}
|
||||
|
||||
var logger = _loggersByName[name];
|
||||
if (!logger) {
|
||||
logger = _loggersByName[name] = new Logger(
|
||||
name,
|
||||
defaultLogger.methodFactory
|
||||
);
|
||||
}
|
||||
return logger;
|
||||
};
|
||||
|
||||
// Grab the current global log variable in case of overwrite
|
||||
var _log = (typeof window !== undefinedType) ? window.log : undefined;
|
||||
defaultLogger.noConflict = function() {
|
||||
if (typeof window !== undefinedType &&
|
||||
window.log === defaultLogger) {
|
||||
window.log = _log;
|
||||
}
|
||||
|
||||
return defaultLogger;
|
||||
};
|
||||
|
||||
defaultLogger.getLoggers = function getLoggers() {
|
||||
return _loggersByName;
|
||||
};
|
||||
|
||||
// ES6 default export, for compatibility
|
||||
defaultLogger['default'] = defaultLogger;
|
||||
|
||||
return defaultLogger;
|
||||
}));
|
||||
3
node_modules/loglevel/dist/loglevel.min.js
generated
vendored
Normal file
3
node_modules/loglevel/dist/loglevel.min.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*! loglevel - v1.9.2 - https://github.com/pimterry/loglevel - (c) 2024 Tim Perry - licensed MIT */
|
||||
|
||||
!function(e,o){"use strict";"function"==typeof define&&define.amd?define(o):"object"==typeof module&&module.exports?module.exports=o():e.log=o()}(this,function(){"use strict";var l=function(){},f="undefined",i=typeof window!==f&&typeof window.navigator!==f&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],p={},d=null;function r(o,e){var n=o[e];if("function"==typeof n.bind)return n.bind(o);try{return Function.prototype.bind.call(n,o)}catch(e){return function(){return Function.prototype.apply.apply(n,[o,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function v(){for(var e=this.getLevel(),o=0;o<s.length;o++){var n=s[o];this[n]=o<e?l:this.methodFactory(n,e,this.name)}if(this.log=this.debug,typeof console===f&&e<this.levels.SILENT)return"No console available for logging"}function y(e,o,n){return"debug"===(t=e)&&(t="log"),typeof console!==f&&("trace"===t&&i?c:void 0!==console[t]?r(console,t):void 0!==console.log?r(console,"log"):l)||function(e){return function(){typeof console!==f&&(v.call(this),this[e].apply(this,arguments))}}.apply(this,arguments);var t}function n(e,o){var n,t,l,i=this,r="loglevel";function c(){var e;if(typeof window!==f&&r){try{e=window.localStorage[r]}catch(e){}if(typeof e===f)try{var o=window.document.cookie,n=encodeURIComponent(r),t=o.indexOf(n+"=");-1!==t&&(e=/^([^;]+)/.exec(o.slice(t+n.length+1))[1])}catch(e){}return void 0===i.levels[e]&&(e=void 0),e}}function a(e){var o=e;if("string"==typeof o&&void 0!==i.levels[o.toUpperCase()]&&(o=i.levels[o.toUpperCase()]),"number"==typeof o&&0<=o&&o<=i.levels.SILENT)return o;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?r+=":"+e:"symbol"==typeof e&&(r=void 0),i.name=e,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=o||y,i.getLevel=function(){return null!=l?l:null!=t?t:n},i.setLevel=function(e,o){return l=a(e),!1!==o&&function(e){var o=(s[e]||"silent").toUpperCase();if(typeof window!==f&&r){try{return window.localStorage[r]=o}catch(e){}try{window.document.cookie=encodeURIComponent(r)+"="+o+";"}catch(e){}}}(l),v.call(i)},i.setDefaultLevel=function(e){t=a(e),c()||i.setLevel(e,!1)},i.resetLevel=function(){l=null,function(){if(typeof window!==f&&r){try{window.localStorage.removeItem(r)}catch(e){}try{window.document.cookie=encodeURIComponent(r)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),v.call(i)},i.enableAll=function(e){i.setLevel(i.levels.TRACE,e)},i.disableAll=function(e){i.setLevel(i.levels.SILENT,e)},i.rebuild=function(){if(d!==i&&(n=a(d.getLevel())),v.call(i),d===i)for(var e in p)p[e].rebuild()},n=a(d?d.getLevel():"WARN");var u=c();null!=u&&(l=a(u)),v.call(i)}(d=new n).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var o=p[e];return o||(o=p[e]=new n(e,d.methodFactory)),o};var e=typeof window!==f?window.log:void 0;return d.noConflict=function(){return typeof window!==f&&window.log===d&&(window.log=e),d},d.getLoggers=function(){return p},d.default=d});
|
||||
203
node_modules/loglevel/index.d.ts
generated
vendored
Normal file
203
node_modules/loglevel/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
// Originally from Definitely Typed, see:
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b4683d7/types/loglevel/index.d.ts
|
||||
// Original definitions by: Stefan Profanter <https://github.com/Pro>
|
||||
// Gabor Szmetanko <https://github.com/szmeti>
|
||||
// Christian Rackerseder <https://github.com/screendriver>
|
||||
|
||||
declare const log: log.RootLogger;
|
||||
export = log;
|
||||
|
||||
declare namespace log {
|
||||
/**
|
||||
* Log levels
|
||||
*/
|
||||
interface LogLevel {
|
||||
TRACE: 0;
|
||||
DEBUG: 1;
|
||||
INFO: 2;
|
||||
WARN: 3;
|
||||
ERROR: 4;
|
||||
SILENT: 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible log level numbers.
|
||||
*/
|
||||
type LogLevelNumbers = LogLevel[keyof LogLevel];
|
||||
|
||||
/**
|
||||
* Possible log level descriptors, may be string, lower or upper case, or number.
|
||||
*/
|
||||
type LogLevelDesc = LogLevelNumbers | LogLevelNames | 'silent' | keyof LogLevel;
|
||||
|
||||
type LogLevelNames =
|
||||
| 'trace'
|
||||
| 'debug'
|
||||
| 'info'
|
||||
| 'warn'
|
||||
| 'error';
|
||||
|
||||
type LoggingMethod = (...message: any[]) => void;
|
||||
|
||||
type MethodFactory = (methodName: LogLevelNames, level: LogLevelNumbers, loggerName: string | symbol) => LoggingMethod;
|
||||
|
||||
interface RootLogger extends Logger {
|
||||
/**
|
||||
* If you're using another JavaScript library that exposes a 'log' global, you can run into conflicts with loglevel.
|
||||
* Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded
|
||||
* onto the page. This resets to 'log' global to its value before loglevel was loaded (typically undefined), and
|
||||
* returns the loglevel object, which you can then bind to another name yourself.
|
||||
*/
|
||||
noConflict(): any;
|
||||
|
||||
/**
|
||||
* This gets you a new logger object that works exactly like the root log object, but can have its level and
|
||||
* logging methods set independently. All loggers must have a name (which is a non-empty string or a symbol)
|
||||
* Calling * getLogger() multiple times with the same name will return an identical logger object.
|
||||
* In large applications, it can be incredibly useful to turn logging on and off for particular modules as you are
|
||||
* working with them. Using the getLogger() method lets you create a separate logger for each part of your
|
||||
* application with its own logging level. Likewise, for small, independent modules, using a named logger instead
|
||||
* of the default root logger allows developers using your module to selectively turn on deep, trace-level logging
|
||||
* when trying to debug problems, while logging only errors or silencing logging altogether under normal
|
||||
* circumstances.
|
||||
* @param name The name of the produced logger
|
||||
*/
|
||||
getLogger(name: string | symbol): Logger;
|
||||
|
||||
/**
|
||||
* This will return you the dictionary of all loggers created with getLogger, keyed off of their names.
|
||||
*/
|
||||
getLoggers(): { [name: string]: Logger };
|
||||
|
||||
/**
|
||||
* A .default property for ES6 default import compatibility
|
||||
*/
|
||||
default: RootLogger;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
/**
|
||||
* Available log levels.
|
||||
*/
|
||||
readonly levels: LogLevel;
|
||||
|
||||
/**
|
||||
* Plugin API entry point. This will be called for each enabled method each time the level is set
|
||||
* (including initially), and should return a MethodFactory to be used for the given log method, at the given level,
|
||||
* for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's
|
||||
* recommended that this wraps the initially provided value of log.methodFactory
|
||||
*/
|
||||
methodFactory: MethodFactory;
|
||||
|
||||
/**
|
||||
* Output trace message to console.
|
||||
* This will also include a full stack trace
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
trace(...msg: any[]): void;
|
||||
|
||||
/**
|
||||
* Output debug message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
debug(...msg: any[]): void;
|
||||
|
||||
/**
|
||||
* Output debug message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
log(...msg: any[]): void;
|
||||
|
||||
/**
|
||||
* Output info message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
info(...msg: any[]): void;
|
||||
|
||||
/**
|
||||
* Output warn message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
warn(...msg: any[]): void;
|
||||
|
||||
/**
|
||||
* Output error message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
error(...msg: any[]): void;
|
||||
|
||||
/**
|
||||
* This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
|
||||
* or log.error("something") will output messages, but log.info("something") will not.
|
||||
*
|
||||
* @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
|
||||
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
|
||||
* back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
||||
* false as the optional 'persist' second argument, persistence will be skipped.
|
||||
*/
|
||||
setLevel(level: LogLevelDesc, persist?: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns the current logging level, as a value from LogLevel.
|
||||
* It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin
|
||||
* development, and partly to let you optimize logging code as below, where debug data is only generated if the
|
||||
* level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling
|
||||
* on your code and you have hard numbers telling you that your log data generation is a real performance problem.
|
||||
*/
|
||||
getLevel(): LogLevel[keyof LogLevel];
|
||||
|
||||
/**
|
||||
* This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when
|
||||
* initializing scripts; if a developer or user has previously called setLevel(), this won’t alter their settings.
|
||||
* For example, your application might set the log level to error in a production environment, but when debugging
|
||||
* an issue, you might call setLevel("trace") on the console to see all the logs. If that error setting was set
|
||||
* using setDefaultLevel(), it will still say as trace on subsequent page loads and refreshes instead of resetting
|
||||
* to error.
|
||||
*
|
||||
* The level argument takes is the same values that you might pass to setLevel(). Levels set using
|
||||
* setDefaultLevel() never persist to subsequent page loads.
|
||||
*
|
||||
* @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
|
||||
*/
|
||||
setDefaultLevel(level: LogLevelDesc): void;
|
||||
|
||||
/**
|
||||
* This resets the current log level to the default level (or `warn` if no explicit default was set) and clears
|
||||
* the persisted level if one was previously persisted.
|
||||
*/
|
||||
resetLevel(): void;
|
||||
|
||||
/**
|
||||
* This enables all log messages, and is equivalent to log.setLevel("trace").
|
||||
*
|
||||
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
|
||||
* back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
||||
* false as the optional 'persist' second argument, persistence will be skipped.
|
||||
*/
|
||||
enableAll(persist?: boolean): void;
|
||||
|
||||
/**
|
||||
* This disables all log messages, and is equivalent to log.setLevel("silent").
|
||||
*
|
||||
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
|
||||
* back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
||||
* false as the optional 'persist' second argument, persistence will be skipped.
|
||||
*/
|
||||
disableAll(persist?: boolean): void;
|
||||
|
||||
/**
|
||||
* Rebuild the logging methods on this logger and its child loggers.
|
||||
*
|
||||
* This is mostly intended for plugin developers, but can be useful if you update a logger's `methodFactory` or
|
||||
* if you want to apply the root logger’s level to any *pre-existing* child loggers (this updates the level on
|
||||
* any child logger that hasn't used `setLevel()` or `setDefaultLevel()`).
|
||||
*/
|
||||
rebuild(): void;
|
||||
}
|
||||
}
|
||||
357
node_modules/loglevel/lib/loglevel.js
generated
vendored
Normal file
357
node_modules/loglevel/lib/loglevel.js
generated
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* loglevel - https://github.com/pimterry/loglevel
|
||||
*
|
||||
* Copyright (c) 2013 Tim Perry
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
(function (root, definition) {
|
||||
"use strict";
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(definition);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
module.exports = definition();
|
||||
} else {
|
||||
root.log = definition();
|
||||
}
|
||||
}(this, function () {
|
||||
"use strict";
|
||||
|
||||
// Slightly dubious tricks to cut down minimized file size
|
||||
var noop = function() {};
|
||||
var undefinedType = "undefined";
|
||||
var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
|
||||
/Trident\/|MSIE /.test(window.navigator.userAgent)
|
||||
);
|
||||
|
||||
var logMethods = [
|
||||
"trace",
|
||||
"debug",
|
||||
"info",
|
||||
"warn",
|
||||
"error"
|
||||
];
|
||||
|
||||
var _loggersByName = {};
|
||||
var defaultLogger = null;
|
||||
|
||||
// Cross-browser bind equivalent that works at least back to IE6
|
||||
function bindMethod(obj, methodName) {
|
||||
var method = obj[methodName];
|
||||
if (typeof method.bind === 'function') {
|
||||
return method.bind(obj);
|
||||
} else {
|
||||
try {
|
||||
return Function.prototype.bind.call(method, obj);
|
||||
} catch (e) {
|
||||
// Missing bind shim or IE8 + Modernizr, fallback to wrapping
|
||||
return function() {
|
||||
return Function.prototype.apply.apply(method, [obj, arguments]);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trace() doesn't print the message in IE, so for that case we need to wrap it
|
||||
function traceForIE() {
|
||||
if (console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
// In old IE, native console methods themselves don't have apply().
|
||||
Function.prototype.apply.apply(console.log, [console, arguments]);
|
||||
}
|
||||
}
|
||||
if (console.trace) console.trace();
|
||||
}
|
||||
|
||||
// Build the best logging method possible for this env
|
||||
// Wherever possible we want to bind, not wrap, to preserve stack traces
|
||||
function realMethod(methodName) {
|
||||
if (methodName === 'debug') {
|
||||
methodName = 'log';
|
||||
}
|
||||
|
||||
if (typeof console === undefinedType) {
|
||||
return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
|
||||
} else if (methodName === 'trace' && isIE) {
|
||||
return traceForIE;
|
||||
} else if (console[methodName] !== undefined) {
|
||||
return bindMethod(console, methodName);
|
||||
} else if (console.log !== undefined) {
|
||||
return bindMethod(console, 'log');
|
||||
} else {
|
||||
return noop;
|
||||
}
|
||||
}
|
||||
|
||||
// These private functions always need `this` to be set properly
|
||||
|
||||
function replaceLoggingMethods() {
|
||||
/*jshint validthis:true */
|
||||
var level = this.getLevel();
|
||||
|
||||
// Replace the actual methods.
|
||||
for (var i = 0; i < logMethods.length; i++) {
|
||||
var methodName = logMethods[i];
|
||||
this[methodName] = (i < level) ?
|
||||
noop :
|
||||
this.methodFactory(methodName, level, this.name);
|
||||
}
|
||||
|
||||
// Define log.log as an alias for log.debug
|
||||
this.log = this.debug;
|
||||
|
||||
// Return any important warnings.
|
||||
if (typeof console === undefinedType && level < this.levels.SILENT) {
|
||||
return "No console available for logging";
|
||||
}
|
||||
}
|
||||
|
||||
// In old IE versions, the console isn't present until you first open it.
|
||||
// We build realMethod() replacements here that regenerate logging methods
|
||||
function enableLoggingWhenConsoleArrives(methodName) {
|
||||
return function () {
|
||||
if (typeof console !== undefinedType) {
|
||||
replaceLoggingMethods.call(this);
|
||||
this[methodName].apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// By default, we use closely bound real methods wherever possible, and
|
||||
// otherwise we wait for a console to appear, and then try again.
|
||||
function defaultMethodFactory(methodName, _level, _loggerName) {
|
||||
/*jshint validthis:true */
|
||||
return realMethod(methodName) ||
|
||||
enableLoggingWhenConsoleArrives.apply(this, arguments);
|
||||
}
|
||||
|
||||
function Logger(name, factory) {
|
||||
// Private instance variables.
|
||||
var self = this;
|
||||
/**
|
||||
* The level inherited from a parent logger (or a global default). We
|
||||
* cache this here rather than delegating to the parent so that it stays
|
||||
* in sync with the actual logging methods that we have installed (the
|
||||
* parent could change levels but we might not have rebuilt the loggers
|
||||
* in this child yet).
|
||||
* @type {number}
|
||||
*/
|
||||
var inheritedLevel;
|
||||
/**
|
||||
* The default level for this logger, if any. If set, this overrides
|
||||
* `inheritedLevel`.
|
||||
* @type {number|null}
|
||||
*/
|
||||
var defaultLevel;
|
||||
/**
|
||||
* A user-specific level for this logger. If set, this overrides
|
||||
* `defaultLevel`.
|
||||
* @type {number|null}
|
||||
*/
|
||||
var userLevel;
|
||||
|
||||
var storageKey = "loglevel";
|
||||
if (typeof name === "string") {
|
||||
storageKey += ":" + name;
|
||||
} else if (typeof name === "symbol") {
|
||||
storageKey = undefined;
|
||||
}
|
||||
|
||||
function persistLevelIfPossible(levelNum) {
|
||||
var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
|
||||
|
||||
if (typeof window === undefinedType || !storageKey) return;
|
||||
|
||||
// Use localStorage if available
|
||||
try {
|
||||
window.localStorage[storageKey] = levelName;
|
||||
return;
|
||||
} catch (ignore) {}
|
||||
|
||||
// Use session cookie as fallback
|
||||
try {
|
||||
window.document.cookie =
|
||||
encodeURIComponent(storageKey) + "=" + levelName + ";";
|
||||
} catch (ignore) {}
|
||||
}
|
||||
|
||||
function getPersistedLevel() {
|
||||
var storedLevel;
|
||||
|
||||
if (typeof window === undefinedType || !storageKey) return;
|
||||
|
||||
try {
|
||||
storedLevel = window.localStorage[storageKey];
|
||||
} catch (ignore) {}
|
||||
|
||||
// Fallback to cookies if local storage gives us nothing
|
||||
if (typeof storedLevel === undefinedType) {
|
||||
try {
|
||||
var cookie = window.document.cookie;
|
||||
var cookieName = encodeURIComponent(storageKey);
|
||||
var location = cookie.indexOf(cookieName + "=");
|
||||
if (location !== -1) {
|
||||
storedLevel = /^([^;]+)/.exec(
|
||||
cookie.slice(location + cookieName.length + 1)
|
||||
)[1];
|
||||
}
|
||||
} catch (ignore) {}
|
||||
}
|
||||
|
||||
// If the stored level is not valid, treat it as if nothing was stored.
|
||||
if (self.levels[storedLevel] === undefined) {
|
||||
storedLevel = undefined;
|
||||
}
|
||||
|
||||
return storedLevel;
|
||||
}
|
||||
|
||||
function clearPersistedLevel() {
|
||||
if (typeof window === undefinedType || !storageKey) return;
|
||||
|
||||
// Use localStorage if available
|
||||
try {
|
||||
window.localStorage.removeItem(storageKey);
|
||||
} catch (ignore) {}
|
||||
|
||||
// Use session cookie as fallback
|
||||
try {
|
||||
window.document.cookie =
|
||||
encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
||||
} catch (ignore) {}
|
||||
}
|
||||
|
||||
function normalizeLevel(input) {
|
||||
var level = input;
|
||||
if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
|
||||
level = self.levels[level.toUpperCase()];
|
||||
}
|
||||
if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
|
||||
return level;
|
||||
} else {
|
||||
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Public logger API - see https://github.com/pimterry/loglevel for details
|
||||
*
|
||||
*/
|
||||
|
||||
self.name = name;
|
||||
|
||||
self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
|
||||
"ERROR": 4, "SILENT": 5};
|
||||
|
||||
self.methodFactory = factory || defaultMethodFactory;
|
||||
|
||||
self.getLevel = function () {
|
||||
if (userLevel != null) {
|
||||
return userLevel;
|
||||
} else if (defaultLevel != null) {
|
||||
return defaultLevel;
|
||||
} else {
|
||||
return inheritedLevel;
|
||||
}
|
||||
};
|
||||
|
||||
self.setLevel = function (level, persist) {
|
||||
userLevel = normalizeLevel(level);
|
||||
if (persist !== false) { // defaults to true
|
||||
persistLevelIfPossible(userLevel);
|
||||
}
|
||||
|
||||
// NOTE: in v2, this should call rebuild(), which updates children.
|
||||
return replaceLoggingMethods.call(self);
|
||||
};
|
||||
|
||||
self.setDefaultLevel = function (level) {
|
||||
defaultLevel = normalizeLevel(level);
|
||||
if (!getPersistedLevel()) {
|
||||
self.setLevel(level, false);
|
||||
}
|
||||
};
|
||||
|
||||
self.resetLevel = function () {
|
||||
userLevel = null;
|
||||
clearPersistedLevel();
|
||||
replaceLoggingMethods.call(self);
|
||||
};
|
||||
|
||||
self.enableAll = function(persist) {
|
||||
self.setLevel(self.levels.TRACE, persist);
|
||||
};
|
||||
|
||||
self.disableAll = function(persist) {
|
||||
self.setLevel(self.levels.SILENT, persist);
|
||||
};
|
||||
|
||||
self.rebuild = function () {
|
||||
if (defaultLogger !== self) {
|
||||
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
||||
}
|
||||
replaceLoggingMethods.call(self);
|
||||
|
||||
if (defaultLogger === self) {
|
||||
for (var childName in _loggersByName) {
|
||||
_loggersByName[childName].rebuild();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize all the internal levels.
|
||||
inheritedLevel = normalizeLevel(
|
||||
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
||||
);
|
||||
var initialLevel = getPersistedLevel();
|
||||
if (initialLevel != null) {
|
||||
userLevel = normalizeLevel(initialLevel);
|
||||
}
|
||||
replaceLoggingMethods.call(self);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Top-level API
|
||||
*
|
||||
*/
|
||||
|
||||
defaultLogger = new Logger();
|
||||
|
||||
defaultLogger.getLogger = function getLogger(name) {
|
||||
if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
|
||||
throw new TypeError("You must supply a name when creating a logger.");
|
||||
}
|
||||
|
||||
var logger = _loggersByName[name];
|
||||
if (!logger) {
|
||||
logger = _loggersByName[name] = new Logger(
|
||||
name,
|
||||
defaultLogger.methodFactory
|
||||
);
|
||||
}
|
||||
return logger;
|
||||
};
|
||||
|
||||
// Grab the current global log variable in case of overwrite
|
||||
var _log = (typeof window !== undefinedType) ? window.log : undefined;
|
||||
defaultLogger.noConflict = function() {
|
||||
if (typeof window !== undefinedType &&
|
||||
window.log === defaultLogger) {
|
||||
window.log = _log;
|
||||
}
|
||||
|
||||
return defaultLogger;
|
||||
};
|
||||
|
||||
defaultLogger.getLoggers = function getLoggers() {
|
||||
return _loggersByName;
|
||||
};
|
||||
|
||||
// ES6 default export, for compatibility
|
||||
defaultLogger['default'] = defaultLogger;
|
||||
|
||||
return defaultLogger;
|
||||
}));
|
||||
63
node_modules/loglevel/package.json
generated
vendored
Normal file
63
node_modules/loglevel/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "loglevel",
|
||||
"description": "Minimal lightweight logging for JavaScript, adding reliable log level methods to any available console.log methods",
|
||||
"version": "1.9.2",
|
||||
"homepage": "https://github.com/pimterry/loglevel",
|
||||
"author": {
|
||||
"name": "Tim Perry",
|
||||
"email": "pimterry@gmail.com",
|
||||
"url": "http://tim-perry.co.uk"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/pimterry/loglevel.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pimterry/loglevel/issues"
|
||||
},
|
||||
"funding": {
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/loglevel"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "lib/loglevel.js",
|
||||
"types": "./index.d.ts",
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "grunt jshint",
|
||||
"test": "grunt test && npm run test-types",
|
||||
"test-browser": "grunt test-browser",
|
||||
"test-node": "grunt test-node",
|
||||
"test-types": "tsc --noEmit ./test/type-test.ts && ts-node ./test/type-test.ts",
|
||||
"dist": "grunt dist",
|
||||
"dist-build": "grunt dist-build",
|
||||
"watch": "grunt watch"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/core-js": "2.5.0",
|
||||
"@types/node": "^12.0.4",
|
||||
"grunt": "~1.5.3",
|
||||
"grunt-cli": "^1.4.3",
|
||||
"grunt-contrib-clean": "^1.1.0",
|
||||
"grunt-contrib-concat": "~0.5.0",
|
||||
"grunt-contrib-connect": "^3.0.0",
|
||||
"grunt-contrib-jasmine": "^4.0.0",
|
||||
"grunt-contrib-jshint": "^3.2.0",
|
||||
"grunt-contrib-uglify": "^3.4.0",
|
||||
"grunt-contrib-watch": "^1.1.0",
|
||||
"grunt-open": "~0.2.3",
|
||||
"grunt-preprocess": "^5.1.0",
|
||||
"jasmine": "^2.4.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^3.5.1"
|
||||
},
|
||||
"keywords": [
|
||||
"log",
|
||||
"logger",
|
||||
"logging",
|
||||
"browser"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user