import { displayDateTime } from 'shared/services/loc' ; export function formatTabs ( level ) { const tabs = [ ] ; while ( level > 1 ) { tabs . push ( '\t' ) ; level -- ; } return tabs . join ( '' ) ; } export function formatCmd ( item ) { const time = displayDateTime ( item . time ) ; const { args = '' , program } = item ; if ( item . event === 'session.exec' ) { const [ path , cmd ] = splitProgramPath ( program ) ; return [ time , path , cmd , args ] . join ( '\t' ) ; } return [ time , '?' , program ] . join ( '\t' ) ; } export function formatFile ( item ) { const { path } = item ; return [ 'file' , path ] . join ( '\t' ) ; } export function formatNetwork ( item ) { const { src , dest } = item ; return [ 'network' , src , '->' , dest ] . join ( '\t' ) ; } export function splitProgramPath ( program ) { const temp = program . split ( '/' ) ; if ( temp . length === 1 ) { return program ; } program = temp . pop ( ) ; return [ temp . join ( '/' ) , program ] ; }