File tree Expand file tree Collapse file tree 3 files changed +36
-5
lines changed
Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Original file line number Diff line number Diff line change 1- import browser from "webextension-polyfill" ;
1+ import Browser from "webextension-polyfill" ;
2+ import { initTracker } from "./tracker" ;
3+ import { logger } from "./compositions/logger" ;
24
3- console . log ( "Start background script" ) ;
5+ logger . log ( "Start background script" ) ;
46
5- browser . runtime . onInstalled . addListener ( ( details ) => {
6- console . log ( "Extension installed:" , details ) ;
7+ Browser . runtime . onInstalled . addListener ( ( details ) => {
8+ logger . log ( "Extension installed:" , details ) ;
79} ) ;
10+
11+ initTracker ( ) ;
Original file line number Diff line number Diff line change 1+ function print ( logFn : typeof console . log , style : string , ...args : any [ ] ) {
2+ if ( typeof args [ 0 ] === 'string' ) {
3+ const newArgs = [ ...args ] ;
4+ logFn (
5+ `%cWeb Activity Time Tracker%c${ new Date ( ) . toLocaleTimeString ( ) } %c ${ newArgs . shift ( ) } ` ,
6+ style ,
7+ 'background-color: #eaf1fb; padding: 2px 4px; border-radius: 3px' ,
8+ '' ,
9+ ...newArgs ,
10+ ) ;
11+ } else {
12+ logFn ( '%cWeb Activity Time Tracker' , style , ...args ) ;
13+ }
14+ }
15+
16+ export function log ( ...args : any [ ] ) {
17+ if ( __DEV__ )
18+ print (
19+ console . log ,
20+ 'color: white; background-color: #1e8e3e; padding: 2px 4px; border-radius: 3px; font-weight: bold' ,
21+ ...args ,
22+ ) ;
23+ }
24+
25+
26+ export const logger = {
27+ log,
28+ } ;
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ async function createAndInitInstance() {
1111
1212export async function injectTabsRepository ( ) : Promise < ITabsRepository > {
1313 if ( instanse == null ) {
14- console . log ( "test" ) ;
1514 instanse = await createAndInitInstance ( ) ;
1615 }
1716 return instanse ;
You can’t perform that action at this time.
0 commit comments