github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/core/auditlog/config.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package auditlog 5 6 import ( 7 "github.com/juju/collections/set" 8 "github.com/juju/errors" 9 ) 10 11 // Config holds parameters to control audit logging. 12 type Config struct { 13 // Enabled determines whether API requests should be audited at 14 // all. 15 Enabled bool 16 17 // CaptureAPIArgs says whether to capture API method args (command 18 // line args will always be captured). 19 CaptureAPIArgs bool 20 21 // MaxSizeMB defines the maximum log file size. 22 MaxSizeMB int 23 24 // MaxBackups determines how many files back to keep. 25 MaxBackups int 26 27 // ExcludeMethods is a set of facade.method names that we 28 // shouldn't consider to be interesting: if a conversation only 29 // consists of these method calls we won't log it. 30 ExcludeMethods set.Strings 31 32 // Target is the AuditLog entries should be written to. 33 Target AuditLog 34 } 35 36 // Validate checks the audit logging configuration. 37 func (cfg Config) Validate() error { 38 if cfg.Enabled && cfg.Target == nil { 39 return errors.NewNotValid(nil, "logging enabled but no target provided") 40 } 41 return nil 42 }