All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.2 KiB

1 year ago
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2020-2021 DnD5e Helpers Team and Contributors
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. import { MODULE } from './module.js'
  25. export class logger {
  26. static info(...args) {
  27. console.log(`${MODULE?.data?.title ?? "" } | `, ...args);
  28. }
  29. static debug(...args) {
  30. if (MODULE.setting('debug'))
  31. console.debug(`${MODULE?.data?.title ?? "" } | `, ...args);
  32. }
  33. static warn(...args) {
  34. console.warn(`${MODULE?.data?.title ?? "" } | WARNING | `, ...args);
  35. ui.notifications.warn(`${MODULE?.data?.title ?? "" } | WARNING | ${args[0]}`);
  36. }
  37. static error(...args) {
  38. console.error(`${MODULE?.data?.title ?? "" } | ERROR | `, ...args);
  39. ui.notifications.error(`${MODULE?.data?.title ?? "" } | ERROR | ${args[0]}`);
  40. }
  41. static catchThrow(thrown, toastMsg = undefined) {
  42. console.warn(thrown);
  43. if(toastMsg) logger.error(toastMsg);
  44. }
  45. static register(){
  46. this.settings()
  47. }
  48. static settings(){
  49. const config = true;
  50. const settingsData = {
  51. debug : {
  52. scope: "client", config, default: false, type: Boolean,
  53. },
  54. };
  55. MODULE.applySettings(settingsData);
  56. }
  57. }