fix: corrige erros de sintaxe ES6 - tudo para IIFE
- Converte logger.js para IIFE (remove export) - Converte state.js para IIFE (remove export) - Remove imports de app.js - Corrige referências aos scripts de teste removidos - Adiciona scripts de teste corretos
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
* Logger com níveis de debug
|
||||
* Substitui console.log dispersos pelo código
|
||||
*/
|
||||
const Logger = (function() {
|
||||
const LEVELS = {
|
||||
var Logger = (function() {
|
||||
var LEVELS = {
|
||||
debug: 0,
|
||||
info: 1,
|
||||
warn: 2,
|
||||
error: 3
|
||||
};
|
||||
|
||||
let currentLevel = LEVELS.info;
|
||||
var currentLevel = LEVELS.info;
|
||||
|
||||
function setLevel(level) {
|
||||
if (LEVELS[level] !== undefined) {
|
||||
@@ -22,26 +22,26 @@ const Logger = (function() {
|
||||
return LEVELS[level] >= currentLevel;
|
||||
}
|
||||
|
||||
function formatMessage(level, ...args) {
|
||||
const timestamp = new Date().toISOString().slice(11, 19);
|
||||
return `[${timestamp}] [${level.toUpperCase()}]`;
|
||||
function formatMessage(level) {
|
||||
var timestamp = new Date().toISOString().slice(11, 19);
|
||||
return '[' + timestamp + '] [' + level.toUpperCase() + ']';
|
||||
}
|
||||
|
||||
return {
|
||||
debug: function(...args) {
|
||||
if (shouldLog('debug')) console.debug(formatMessage('debug', ...args), ...args);
|
||||
debug: function() {
|
||||
if (shouldLog('debug')) console.debug(formatMessage('debug'), arguments);
|
||||
},
|
||||
|
||||
info: function(...args) {
|
||||
if (shouldLog('info')) console.info(formatMessage('info', ...args), ...args);
|
||||
info: function() {
|
||||
if (shouldLog('info')) console.info(formatMessage('info'), arguments);
|
||||
},
|
||||
|
||||
warn: function(...args) {
|
||||
if (shouldLog('warn')) console.warn(formatMessage('warn', ...args), ...args);
|
||||
warn: function() {
|
||||
if (shouldLog('warn')) console.warn(formatMessage('warn'), arguments);
|
||||
},
|
||||
|
||||
error: function(...args) {
|
||||
if (shouldLog('error')) console.error(formatMessage('error', ...args), ...args);
|
||||
error: function() {
|
||||
if (shouldLog('error')) console.error(formatMessage('error'), arguments);
|
||||
},
|
||||
|
||||
setLevel: setLevel,
|
||||
@@ -56,5 +56,4 @@ const Logger = (function() {
|
||||
};
|
||||
})();
|
||||
|
||||
window.Logger = Logger;
|
||||
export default Logger;
|
||||
window.Logger = Logger;
|
||||
Reference in New Issue
Block a user