mirror of
https://github.com/koreanbots/core.git
synced 2025-12-17 06:40:24 +00:00
feat: applying new logger
This commit is contained in:
parent
17b965547e
commit
4d6a65c5a4
@ -1,3 +1,4 @@
|
|||||||
|
import { Logger } from '@utils/Logger'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
const Advertisement = ({ size='short' }:AdvertisementProps): JSX.Element => {
|
const Advertisement = ({ size='short' }:AdvertisementProps): JSX.Element => {
|
||||||
@ -5,7 +6,7 @@ const Advertisement = ({ size='short' }:AdvertisementProps): JSX.Element => {
|
|||||||
if(process.env.NODE_ENV === 'production') {
|
if(process.env.NODE_ENV === 'production') {
|
||||||
window.adsbygoogle = window.adsbygoogle || []
|
window.adsbygoogle = window.adsbygoogle || []
|
||||||
window.adsbygoogle.push({})
|
window.adsbygoogle.push({})
|
||||||
} else console.log('Ads Pushed')
|
} else Logger.debug('Ads Pushed')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <div className={`z-0 mx-auto w-full text-center text-white ${process.env.NODE_ENV === 'production' ? '' : 'py-12 bg-gray-700'}`} style={size === 'short' ? { height: '90px' } : { height: '330px'}}>
|
return <div className={`z-0 mx-auto w-full text-center text-white ${process.env.NODE_ENV === 'production' ? '' : 'py-12 bg-gray-700'}`} style={size === 'short' ? { height: '90px' } : { height: '330px'}}>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { SyntheticEvent, useEffect, useState } from 'react'
|
import { SyntheticEvent, useEffect, useState } from 'react'
|
||||||
import { KoreanbotsEndPoints } from '@utils/Constants'
|
import { KoreanbotsEndPoints } from '@utils/Constants'
|
||||||
import { supportsWebP } from '@utils/Tools'
|
import { supportsWebP } from '@utils/Tools'
|
||||||
|
import { Logger } from '@utils/Logger'
|
||||||
|
|
||||||
const DiscordAvatar = (props: {
|
const DiscordAvatar = (props: {
|
||||||
alt?: string
|
alt?: string
|
||||||
@ -25,7 +26,7 @@ const DiscordAvatar = (props: {
|
|||||||
if(webpUnavailable) {
|
if(webpUnavailable) {
|
||||||
(e.target as ImageTarget).onerror = (event) => {
|
(e.target as ImageTarget).onerror = (event) => {
|
||||||
// All Fails
|
// All Fails
|
||||||
(event.target as ImageTarget).onerror = ()=> { console.log('FALLBACK IMAGE LOAD FAIL') }
|
(event.target as ImageTarget).onerror = ()=> { Logger.warn('FALLBACK IMAGE LOAD FAIL') }
|
||||||
(event.target as ImageTarget).src = fallback
|
(event.target as ImageTarget).src = fallback
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -33,7 +34,7 @@ const DiscordAvatar = (props: {
|
|||||||
else {
|
else {
|
||||||
(e.target as ImageTarget).onerror = (event) => {
|
(e.target as ImageTarget).onerror = (event) => {
|
||||||
// All Fails
|
// All Fails
|
||||||
(event.target as ImageTarget).onerror = ()=> { console.log('FALLBACK IMAGE LOAD FAIL') }
|
(event.target as ImageTarget).onerror = ()=> { Logger.warn('FALLBACK IMAGE LOAD FAIL') }
|
||||||
(event.target as ImageTarget).src = fallback
|
(event.target as ImageTarget).src = fallback
|
||||||
}
|
}
|
||||||
// Webp Load Fail
|
// Webp Load Fail
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import '../app.css'
|
|||||||
import '@fortawesome/fontawesome-free/css/all.css'
|
import '@fortawesome/fontawesome-free/css/all.css'
|
||||||
import '../github-markdown.css'
|
import '../github-markdown.css'
|
||||||
import { Theme } from '@types'
|
import { Theme } from '@types'
|
||||||
|
import { Logger } from '@utils/Logger'
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ export default function App({ Component, pageProps, err }: KoreanbotsProps): JSX
|
|||||||
systemColor = 'dark'
|
systemColor = 'dark'
|
||||||
}
|
}
|
||||||
if (!localStorage.theme) {
|
if (!localStorage.theme) {
|
||||||
console.log(`[THEME] ${systemColor.toUpperCase()} THEME DETECTED`)
|
Logger.debug(`[THEME] ${systemColor.toUpperCase()} THEME DETECTED`)
|
||||||
setTheme(systemColor)
|
setTheme(systemColor)
|
||||||
}
|
}
|
||||||
else setTheme(localStorage.theme)
|
else setTheme(localStorage.theme)
|
||||||
|
|||||||
21
utils/Logger.ts
Normal file
21
utils/Logger.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export class Logger {
|
||||||
|
private static genStyle(bg: string, text='black') {
|
||||||
|
return `color:${text};background:${bg};padding:1px 3px;border-radius:2px;margin-right:5px;`
|
||||||
|
}
|
||||||
|
|
||||||
|
private static print(level: string, message: string, style: string) {
|
||||||
|
console.log(`%c${level}` + `%c${message}`, style, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
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'))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user