@@ -10,14 +10,61 @@ import { createPersistedDocuments } from './persisted-documents.js';
1010import { createReporting } from './reporting.js' ;
1111import type { HiveClient , HiveInternalPluginOptions , HivePluginOptions } from './types.js' ;
1212import { createUsage } from './usage.js' ;
13- import { createHiveLogger , isLegacyAccessToken } from './utils.js' ;
13+ import { createHiveLogger , HiveLogger , isLegacyAccessToken } from './utils.js' ;
1414
15- export function createHive ( options : HivePluginOptions ) : HiveClient {
16- const logger = createHiveLogger (
15+ function chooseDefaultLogger ( options : HivePluginOptions ) : HiveLogger {
16+ if ( options . logger === 'debug' ) {
17+ return createHiveLogger (
18+ {
19+ debug ( ...args ) {
20+ console . debug ( ...args ) ;
21+ } ,
22+ info ( ...args ) {
23+ console . info ( ...args ) ;
24+ } ,
25+ error ( ...args ) {
26+ console . error ( ...args ) ;
27+ } ,
28+ } ,
29+ '[hive]' ,
30+ ) ;
31+ }
32+ if ( options . logger === 'info' ) {
33+ return createHiveLogger (
34+ {
35+ debug ( ) { } ,
36+ info ( ...args ) {
37+ console . info ( ...args ) ;
38+ } ,
39+ error ( ...args ) {
40+ console . error ( ...args ) ;
41+ } ,
42+ } ,
43+ '[hive]' ,
44+ ) ;
45+ }
46+ if ( options . logger === 'error' ) {
47+ return createHiveLogger (
48+ {
49+ debug ( ) { } ,
50+ info ( ) { } ,
51+ error ( ...args ) {
52+ console . error ( ...args ) ;
53+ } ,
54+ } ,
55+ '[hive]' ,
56+ ) ;
57+ }
58+
59+ return createHiveLogger (
1760 options ?. logger ?? options ?. agent ?. logger ?? console ,
1861 '[hive]' ,
1962 options . debug ,
2063 ) ;
64+ }
65+
66+ export function createHive ( options : HivePluginOptions ) : HiveClient {
67+ const logger = chooseDefaultLogger ( options ) ;
2168 let enabled = options . enabled ?? true ;
2269
2370 if ( enabled === false && ! options . experimental__persistedDocuments ) {
0 commit comments