Skip to content

Commit

Permalink
feat: used consola instaid of tslog
Browse files Browse the repository at this point in the history
  • Loading branch information
khawarizmus committed Oct 27, 2023
1 parent 59759e5 commit 7759bc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Binary file added bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"dependencies": {
"@rapideditor/country-coder": "^5.2.2",
"adhan": "^4.4.3",
"rxjs": "^7.5.6",
"tslog": "^4.4.4"
"consola": "^3.2.3",
"rxjs": "^7.5.6"
}
}
14 changes: 10 additions & 4 deletions src/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
PrayerTimes,
SunnahTimes,
} from 'adhan'
import type { Logger } from 'tslog'
import { createConsola } from 'consola'
import type { ConsolaInstance } from 'consola'
import { AsrTime } from './types/AsrTime'
import type { CalculationsConfig, CustomMethod } from './types/CalculationsConfig'
import { Methods } from './types/Methods'
Expand All @@ -21,9 +22,16 @@ export class BaseCalculator {
protected _qiyamTimesCalculator!: SunnahTimes
protected _prayerConfig!: CalculationsConfig
protected _qiyamConfig!: CalculationsConfig
protected _logger!: Logger<any>
protected _logger!: ConsolaInstance

constructor(config: CalculationsConfig) {
this._logger = createConsola({
level: config.debug ? 4 : 2,
fancy: config.debug,
formatOptions: {
colors: true,
},
})
this._initializer(config)
}

Expand Down Expand Up @@ -245,9 +253,7 @@ export class BaseCalculator {
calendar: this._prayerConfig.hijriCalendar ?? HijriCalendar.UMM_AL_QURA,
dateStyle: 'short',
})
console.log(hijriFormatter.formatDate(date))
const hijriMonth = hijriFormatter.formatDate(date).split('/')[0]
console.log(hijriMonth)
// check if the month is ramadan
if (parseInt(hijriMonth, 10) === 9) {
if (method === Methods.UMM_AL_QURA || this._prayerConfig.adjustForRamadan) {
Expand Down
7 changes: 0 additions & 7 deletions src/ReactiveCalculator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Observable, defer, merge, timer } from 'rxjs'
import { delay, repeat } from 'rxjs/operators'
import { Coordinates, Prayer, PrayerTimes, Qibla, SunnahTimes } from 'adhan'
import { Logger } from 'tslog'
import type { Subscriber, Subscription } from 'rxjs'

import { BaseCalculator } from './Base'
Expand Down Expand Up @@ -33,12 +32,6 @@ export class ReactiveCalculator extends BaseCalculator {
}
super(config)

this._logger = new Logger({
name: `ReactiveCalculator-${Math.random().toString(36).slice(-6)}`,
minLevel: config.debug ? 2 : 4,
prefix: ['ReactiveCalculator:'],
})

this._logger.debug('logger initialized successfully.')

this._setup()
Expand Down

0 comments on commit 7759bc3

Please sign in to comment.