unipdf/common/common.go

102 lines
7.0 KiB
Go
Raw Normal View History

2020-08-27 21:45:09 +00:00
//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
// Package common contains common properties used by the subpackages.
2020-09-07 00:23:12 +00:00
package common ;import (_a "fmt";_aa "io";_dc "os";_d "path/filepath";_f "runtime";_bg "time";);const _bgg ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Error does nothing for dummy logger.
func (DummyLogger )Error (format string ,args ...interface{}){};
// Info does nothing for dummy logger.
func (DummyLogger )Info (format string ,args ...interface{}){};
// Warning logs warning message.
func (_bfc ConsoleLogger )Warning (format string ,args ...interface{}){if _bfc .LogLevel >=LogLevelWarning {_af :="\u005b\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u005d\u0020";_bfc .output (_dc .Stdout ,_af ,format ,args ...);};};
// WriterLogger is the logger that writes data to the Output writer
type WriterLogger struct{LogLevel LogLevel ;Output _aa .Writer ;};
2020-08-27 21:45:09 +00:00
2020-08-31 21:12:07 +00:00
// LogLevel is the verbosity level for logging.
type LogLevel int ;
2020-09-07 00:23:12 +00:00
// Debug logs debug message.
func (_cb ConsoleLogger )Debug (format string ,args ...interface{}){if _cb .LogLevel >=LogLevelDebug {_edg :="\u005b\u0044\u0045\u0042\u0055\u0047\u005d\u0020";_cb .output (_dc .Stdout ,_edg ,format ,args ...);};};
2020-08-31 21:12:07 +00:00
// IsLogLevel returns true from dummy logger.
func (DummyLogger )IsLogLevel (level LogLevel )bool {return true };
2020-08-27 21:45:09 +00:00
2020-08-31 21:12:07 +00:00
// Error logs error message.
2020-09-07 00:23:12 +00:00
func (_ea ConsoleLogger )Error (format string ,args ...interface{}){if _ea .LogLevel >=LogLevelError {_bb :="\u005b\u0045\u0052\u0052\u004f\u0052\u005d\u0020";_ea .output (_dc .Stdout ,_bb ,format ,args ...);};};const (LogLevelTrace LogLevel =5;LogLevelDebug LogLevel =4;LogLevelInfo LogLevel =3;LogLevelNotice LogLevel =2;LogLevelWarning LogLevel =1;LogLevelError LogLevel =0;);
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Info logs info message.
func (_ff ConsoleLogger )Info (format string ,args ...interface{}){if _ff .LogLevel >=LogLevelInfo {_ca :="\u005bI\u004e\u0046\u004f\u005d\u0020";_ff .output (_dc .Stdout ,_ca ,format ,args ...);};};const _gecb =18;
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Trace logs trace message.
func (_gf ConsoleLogger )Trace (format string ,args ...interface{}){if _gf .LogLevel >=LogLevelTrace {_dcc :="\u005b\u0054\u0052\u0041\u0043\u0045\u005d\u0020";_gf .output (_dc .Stdout ,_dcc ,format ,args ...);};};
2020-08-27 21:45:09 +00:00
2020-08-31 21:12:07 +00:00
// Warning does nothing for dummy logger.
func (DummyLogger )Warning (format string ,args ...interface{}){};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// IsLogLevel returns true if log level is greater or equal than `level`.
// Can be used to avoid resource intensive calls to loggers.
func (_afa WriterLogger )IsLogLevel (level LogLevel )bool {return _afa .LogLevel >=level };
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Trace does nothing for dummy logger.
func (DummyLogger )Trace (format string ,args ...interface{}){};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Notice logs notice message.
func (_ed ConsoleLogger )Notice (format string ,args ...interface{}){if _ed .LogLevel >=LogLevelNotice {_fg :="\u005bN\u004f\u0054\u0049\u0043\u0045\u005d ";_ed .output (_dc .Stdout ,_fg ,format ,args ...);};};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Debug logs debug message.
func (_bfca WriterLogger )Debug (format string ,args ...interface{}){if _bfca .LogLevel >=LogLevelDebug {_de :="\u005b\u0044\u0045\u0042\u0055\u0047\u005d\u0020";_bfca .logToWriter (_bfca .Output ,_de ,format ,args ...);};};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// NewConsoleLogger creates new console logger.
func NewConsoleLogger (logLevel LogLevel )*ConsoleLogger {return &ConsoleLogger {LogLevel :logLevel }};const _cbee =9;
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Notice logs notice message.
func (_ac WriterLogger )Notice (format string ,args ...interface{}){if _ac .LogLevel >=LogLevelNotice {_dgf :="\u005bN\u004f\u0054\u0049\u0043\u0045\u005d ";_ac .logToWriter (_ac .Output ,_dgf ,format ,args ...);};};func (_cc ConsoleLogger )output (_dg _aa .Writer ,_fa string ,_gde string ,_agge ...interface{}){_fad (_dg ,_fa ,_gde ,_agge ...);};
2020-08-27 21:45:09 +00:00
2020-08-31 21:12:07 +00:00
// Trace logs trace message.
2020-09-07 00:23:12 +00:00
func (_ee WriterLogger )Trace (format string ,args ...interface{}){if _ee .LogLevel >=LogLevelTrace {_ggc :="\u005b\u0054\u0052\u0041\u0043\u0045\u005d\u0020";_ee .logToWriter (_ee .Output ,_ggc ,format ,args ...);};};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Warning logs warning message.
func (_cg WriterLogger )Warning (format string ,args ...interface{}){if _cg .LogLevel >=LogLevelWarning {_ge :="\u005b\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u005d\u0020";_cg .logToWriter (_cg .Output ,_ge ,format ,args ...);};};
// Logger is the interface used for logging in the unipdf package.
type Logger interface{Error (_ba string ,_e ...interface{});Warning (_ag string ,_g ...interface{});Notice (_c string ,_cd ...interface{});Info (_agg string ,_gd ...interface{});Debug (_bc string ,_gdd ...interface{});Trace (_dcf string ,_bf ...interface{});IsLogLevel (_bfd LogLevel )bool ;};
2020-08-27 21:45:09 +00:00
// Error logs error message.
2020-09-07 00:23:12 +00:00
func (_ead WriterLogger )Error (format string ,args ...interface{}){if _ead .LogLevel >=LogLevelError {_be :="\u005b\u0045\u0052\u0052\u004f\u0052\u005d\u0020";_ead .logToWriter (_ead .Output ,_be ,format ,args ...);};};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Notice does nothing for dummy logger.
func (DummyLogger )Notice (format string ,args ...interface{}){};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Debug does nothing for dummy logger.
func (DummyLogger )Debug (format string ,args ...interface{}){};var Log Logger =DummyLogger {};const _gec =2020;const _gda =6;func (_da WriterLogger )logToWriter (_eb _aa .Writer ,_db string ,_bgd string ,_dae ...interface{}){_fad (_eb ,_db ,_bgd ,_dae );};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// IsLogLevel returns true if log level is greater or equal than `level`.
// Can be used to avoid resource intensive calls to loggers.
func (_gg ConsoleLogger )IsLogLevel (level LogLevel )bool {return _gg .LogLevel >=level };func UtcTimeFormat (t _bg .Time )string {return t .Format (_bgg )+"\u0020\u0055\u0054\u0043"};var ReleasedAt =_bg .Date (_gec ,_cbee ,_gda ,_gecb ,_eg ,0,0,_bg .UTC );
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// NewWriterLogger creates new 'writer' logger.
func NewWriterLogger (logLevel LogLevel ,writer _aa .Writer )*WriterLogger {_ga :=WriterLogger {Output :writer ,LogLevel :logLevel };return &_ga ;};const Version ="\u0033\u002e\u0031\u0031\u002e\u0030";const _eg =50;
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// ConsoleLogger is a logger that writes logs to the 'os.Stdout'
type ConsoleLogger struct{LogLevel LogLevel ;};
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// DummyLogger does nothing.
type DummyLogger struct{};func _fad (_ace _aa .Writer ,_edb string ,_cga string ,_fd ...interface{}){_ ,_cae ,_ec ,_dbc :=_f .Caller (3);if !_dbc {_cae ="\u003f\u003f\u003f";_ec =0;}else {_cae =_d .Base (_cae );};_fge :=_a .Sprintf ("\u0025s\u0020\u0025\u0073\u003a\u0025\u0064 ",_edb ,_cae ,_ec )+_cga +"\u000a";_a .Fprintf (_ace ,_fge ,_fd ...);};
2020-08-27 21:45:09 +00:00
2020-08-31 21:12:07 +00:00
// SetLogger sets 'logger' to be used by the unidoc unipdf library.
func SetLogger (logger Logger ){Log =logger };
2020-08-27 21:45:09 +00:00
2020-09-07 00:23:12 +00:00
// Info logs info message.
func (_cba WriterLogger )Info (format string ,args ...interface{}){if _cba .LogLevel >=LogLevelInfo {_cbe :="\u005bI\u004e\u0046\u004f\u005d\u0020";_cba .logToWriter (_cba .Output ,_cbe ,format ,args ...);};};