logger.go (1389B)
1 /* 2 exif-terminator 3 Copyright (C) 2022 SuperSeriousBusiness admin@gotosocial.org 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU Affero General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 package terminator 20 21 import "fmt" 22 23 var logger ErrorLogger 24 25 func init() { 26 logger = &defaultErrorLogger{} 27 } 28 29 // ErrorLogger denotes a generic error logging function. 30 type ErrorLogger interface { 31 Error(args ...interface{}) 32 } 33 34 type defaultErrorLogger struct{} 35 36 func (d *defaultErrorLogger) Error(args ...interface{}) { 37 fmt.Println(args...) 38 } 39 40 // SetErrorLogger allows a user of the exif-terminator library 41 // to set the logger that will be used for error logging. 42 // 43 // If it is not set, the default error logger will be used, which 44 // just prints errors to stdout. 45 func SetErrorLogger(errorLogger ErrorLogger) { 46 logger = errorLogger 47 }