File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { ObjectifyError } from '@idl/error-shared' ;
22import { DEFAULT_IDL_EXTENSION_CONFIG } from '@idl/vscode/extension-config' ;
3+ import copy from 'fast-copy' ;
34
45import {
56 DEFAULT_LOGGER_OPTIONS ,
7+ DEFAULT_TRACKER ,
68 ILogManagerOptions ,
79 ILogOptions ,
810 LogInterceptor ,
@@ -25,8 +27,12 @@ import {
2527 * Manages log collections with the ability to do console and/or file logging.
2628 */
2729export class LogManager implements ILogManagerOptions {
30+ /** Are we debug mode or not? */
2831 debug = DEFAULT_IDL_EXTENSION_CONFIG . debugMode ;
2932
33+ /** Track errors and warnings */
34+ tracker = copy ( DEFAULT_TRACKER ) ;
35+
3036 /** How do we handle existing logs? */
3137 mode : FileLogMode = LOGGING_CONFIG . FILE_LOG_MODE ;
3238
@@ -152,6 +158,18 @@ export class LogManager implements ILogManagerOptions {
152158 return ;
153159 }
154160
161+ // track number of warnings or errors
162+ switch ( options . type ) {
163+ case 'error' :
164+ this . tracker . errors ++ ;
165+ break ;
166+ case 'warn' :
167+ this . tracker . warnings ++ ;
168+ break ;
169+ default :
170+ break ;
171+ }
172+
155173 // check if we have
156174 if ( this . interceptor !== undefined ) {
157175 // get data we are sending
@@ -200,4 +218,11 @@ export class LogManager implements ILogManagerOptions {
200218 break ;
201219 }
202220 }
221+
222+ /**
223+ * Reset counts for types of logs we are tracking
224+ */
225+ resetTracker ( ) {
226+ this . tracker = copy ( DEFAULT_TRACKER ) ;
227+ }
203228}
Original file line number Diff line number Diff line change @@ -45,3 +45,21 @@ export const DEFAULT_LOGGER_OPTIONS: ILogOptions = {
4545 // dont include alert message otherwise we always print since it is present
4646 // alert: IDL_TRANSLATION.logger.defaultErrorMessage,
4747} ;
48+
49+ /**
50+ * Data structure to track different kinds of messages in the logger
51+ */
52+ export interface ILogManagerTracker {
53+ /** NUmber of errors */
54+ errors : number ;
55+ /** Number of warnings */
56+ warnings : number ;
57+ }
58+
59+ /**
60+ * Default values for tracker
61+ */
62+ export const DEFAULT_TRACKER : ILogManagerTracker = {
63+ errors : 0 ,
64+ warnings : 0 ,
65+ } ;
You can’t perform that action at this time.
0 commit comments