storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/logger/targets.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2018 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package logger 18 19 // Target is the entity that we will receive 20 // a single log entry and Send it to the log target 21 // e.g. Send the log to a http server 22 type Target interface { 23 String() string 24 Endpoint() string 25 Validate() error 26 Send(entry interface{}, errKind string) error 27 } 28 29 // Targets is the set of enabled loggers 30 var Targets = []Target{} 31 32 // AuditTargets is the list of enabled audit loggers 33 var AuditTargets = []Target{} 34 35 // AddAuditTarget adds a new audit logger target to the 36 // list of enabled loggers 37 func AddAuditTarget(t Target) error { 38 if err := t.Validate(); err != nil { 39 return err 40 } 41 42 AuditTargets = append(AuditTargets, t) 43 return nil 44 } 45 46 // AddTarget adds a new logger target to the 47 // list of enabled loggers 48 func AddTarget(t Target) error { 49 if err := t.Validate(); err != nil { 50 return err 51 } 52 Targets = append(Targets, t) 53 return nil 54 }