11import logger from '../../logger' ;
2- import { Log , TimeUnit , Weekday } from '../../types' ;
2+ import { TimeUnit , Weekday } from '../../types' ;
33import IncompleteSession from './IncompleteSession' ;
44import SessionHistory from './SessionHistory' ;
55import CompleteSession from './CompleteSession' ;
@@ -8,6 +8,7 @@ import TimeDuration from '../units/TimeDuration';
88import { getRange } from '../../utils/math' ;
99import SessionBucket from '../buckets/SessionBucket' ;
1010import { formatDateForFilename } from '../../utils/locale' ;
11+ import Log from '../../Log' ;
1112
1213const TEXTS = {
1314 SessionStart : '[START]' ,
@@ -40,11 +41,11 @@ class SessionHistoryBuilder {
4041 logs . forEach ( log => {
4142
4243 // Session started
43- if ( log . msg . includes ( TEXTS . SessionStart ) ) {
44+ if ( log . getMessage ( ) . includes ( TEXTS . SessionStart ) ) {
4445 session = IncompleteSession . create ( ) ;
4546
46- logger . trace ( `Starting session: ${ session . getId ( ) } [${ log . version . toJSON ( ) } ]` ) ;
47- session . start ( new Date ( log . time ) ) ;
47+ logger . trace ( `Starting session: ${ session . getId ( ) } [${ log . getVersion ( ) . toJSON ( ) } ]` ) ;
48+ session . start ( log . getTime ( ) ) ;
4849 }
4950
5051 // Session exists and is open: store log
@@ -53,9 +54,9 @@ class SessionHistoryBuilder {
5354 }
5455
5556 // Session ended
56- if ( log . msg . includes ( TEXTS . SessionEnd ) ) {
57- logger . trace ( `Finishing session: ${ session . getId ( ) } [${ log . version . toJSON ( ) } ]` ) ;
58- session . end ( new Date ( log . time ) ) ;
57+ if ( log . getMessage ( ) . includes ( TEXTS . SessionEnd ) ) {
58+ logger . trace ( `Finishing session: ${ session . getId ( ) } [${ log . getVersion ( ) . toJSON ( ) } ]` ) ;
59+ session . end ( log . getTime ( ) ) ;
5960
6061 // Sessions should have a start and an end
6162 if ( ! session . isComplete ( ) ) {
@@ -65,15 +66,15 @@ class SessionHistoryBuilder {
6566 // Has session more than one error: it is invalid!
6667 const errorCount = session . getErrors ( ) . length ;
6768 if ( errorCount > 1 ) {
68- const sessionStartLine = session . getLogs ( ) [ 0 ] . line ;
69- logger . warn ( `Invalid session [${ formatDateForFilename ( session . getStartTime ( ) ! ) } @${ sessionStartLine } ] with ${ errorCount } > 1 errors found` ) ;
69+ const sessionStartLine = session . getLogs ( ) [ 0 ] . getLine ( ) ;
70+ logger . warn ( `Invalid session [${ formatDateForFilename ( session . getStartTime ( ) ! ) } @${ sessionStartLine } ] with ( ${ errorCount } > 1) errors found` ) ;
7071 return ;
7172 }
7273
7374 // Store complete session in history
7475 history . addSession ( new CompleteSession ( {
7576 id : session . getId ( ) ,
76- release : log . version ,
77+ release : log . getVersion ( ) ,
7778 startTime : session . getStartTime ( ) ! ,
7879 endTime : session . getEndTime ( ) ! ,
7980 logs : session . getLogs ( ) ,
0 commit comments