From 75c3a82c9081b4cda76f237107b68874497511ce Mon Sep 17 00:00:00 2001 From: Junseo Park Date: Thu, 25 Feb 2021 13:43:41 +0900 Subject: [PATCH] chore: changed logger export --- components/Advertisement.tsx | 5 +++-- components/DiscordAvatar.tsx | 2 +- pages/_app.tsx | 3 ++- utils/Logger.ts | 35 +++++++++++++++++------------------ 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/components/Advertisement.tsx b/components/Advertisement.tsx index b3efc67..19f7b0e 100644 --- a/components/Advertisement.tsx +++ b/components/Advertisement.tsx @@ -1,4 +1,4 @@ -import { Logger } from '@utils/Logger' +import Logger from '@utils/Logger' import { useEffect } from 'react' const Advertisement = ({ size='short' }:AdvertisementProps): JSX.Element => { @@ -6,7 +6,8 @@ const Advertisement = ({ size='short' }:AdvertisementProps): JSX.Element => { if(process.env.NODE_ENV === 'production') { window.adsbygoogle = window.adsbygoogle || [] window.adsbygoogle.push({}) - } else Logger.debug('Ads Pushed') + } + Logger.debug('Ads Pushed') }, []) return
diff --git a/components/DiscordAvatar.tsx b/components/DiscordAvatar.tsx index b08cb7a..855e30f 100644 --- a/components/DiscordAvatar.tsx +++ b/components/DiscordAvatar.tsx @@ -1,7 +1,7 @@ import { SyntheticEvent, useEffect, useState } from 'react' import { KoreanbotsEndPoints } from '@utils/Constants' import { supportsWebP } from '@utils/Tools' -import { Logger } from '@utils/Logger' +import Logger from '@utils/Logger' const DiscordAvatar = (props: { alt?: string diff --git a/pages/_app.tsx b/pages/_app.tsx index 829ee5e..825298b 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -3,7 +3,9 @@ import type { AppProps } from 'next/app' import dynamic from 'next/dynamic' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' + import { init } from '@utils/Sentry' +import Logger from '@utils/Logger' const Footer = dynamic(() => import('@components/Footer')) const Navbar = dynamic(() => import('@components/Navbar')) @@ -18,7 +20,6 @@ import '../app.css' import '@fortawesome/fontawesome-free/css/all.css' import '../github-markdown.css' import { Theme } from '@types' -import { Logger } from '@utils/Logger' init() diff --git a/utils/Logger.ts b/utils/Logger.ts index e6b2354..fc86244 100644 --- a/utils/Logger.ts +++ b/utils/Logger.ts @@ -1,21 +1,20 @@ -export class Logger { - private static genStyle(bg: string, text='black') { - return `color:${text};background:${bg};padding:1px 3px;border-radius:2px;margin-right:5px;` +const Logger = { + debug: function(message: string) { + print('DEBUG', message, genStyle('cyan')) + }, + warn: function(message: string) { + print('WARN', message, genStyle('yellow')) + }, + error: function(message: string) { + print('ERROR', message, genStyle('red', 'white')) } +} - private static print(level: string, message: string, style: string) { - console.log(`%c${level}` + `%c${message}`, style, '') - } +function genStyle(bg: string, text='black') { + return `color:${text};background:${bg};padding:1px 3px;border-radius:2px;margin-right:5px;` +} - static debug(message: string) { - this.print('DEBUG', message, this.genStyle('cyan')) - } - - static warn(message: string) { - this.print('WARN', message, this.genStyle('yellow')) - } - - static error(message: string) { - this.print('ERROR', message, this.genStyle('red', 'white')) - } -} \ No newline at end of file +function print(level: string, message: string, style: string) { + console.log(`%c${level}` + `%c${message}`, style, '') +} +export default Logger