import { schema , ByteSizeValue } from '@kbn/config-schema' ; import { LogRecord } from '@kbn/logging' ; import { RollingFileContext } from '../../rolling_file_context' ; import { TriggeringPolicy } from '../policy' ; export interface SizeLimitTriggeringPolicyConfig { type : 'size-limit' ; /**
     * The minimum size the file must have to roll over.
     */ size : ByteSizeValue ; } export const sizeLimitTriggeringPolicyConfigSchema = schema . object ( { type : schema . literal ( 'size-limit' ) , size : schema . byteSize ( { min : '1b' , defaultValue : '100mb' } ) , } ) ; /**
 * A triggering policy based on a fixed size limit.
 *
 * Will trigger a rollover when the current log size exceed the
 * given  SizeLimitTriggeringPolicyConfig . size .
  export class SizeLimitTriggeringPolicy implements TriggeringPolicy { private readonly maxFileSize : number ; constructor ( config , private readonly context ) { this . maxFileSize = config . size . getValueInBytes ( ) ; } isTriggeringEvent ( record ) { return this . context . currentFileSize >= this . maxFileSize ; } }