aboutsummaryrefslogtreecommitdiff
path: root/unipdf/common/common.go
blob: e7d3add9c909dadf8eb4c4a689f4e87b7ed55c42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// 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.
package common ;import (_c "fmt";_dc "io";_d "os";_ge "path/filepath";_eg "runtime";_g "time";);

// Logger is the interface used for logging in the unipdf package.
type Logger interface{Error (_cb string ,_b ...interface{});Warning (_gc string ,_bf ...interface{});Notice (_eb string ,_bc ...interface{});Info (_gd string ,_da ...interface{});Debug (_ce string ,_f ...interface{});Trace (_ba string ,_ff ...interface{});
IsLogLevel (_cg LogLevel )bool ;};func _cebc (_fb _dc .Writer ,_bfd string ,_ecd string ,_agg ...interface{}){_ ,_ggb ,_gab ,_gf :=_eg .Caller (3);if !_gf {_ggb ="\u003f\u003f\u003f";_gab =0;}else {_ggb =_ge .Base (_ggb );};_aga :=_c .Sprintf ("\u0025s\u0020\u0025\u0073\u003a\u0025\u0064 ",_bfd ,_ggb ,_gab )+_ecd +"\u000a";
_c .Fprintf (_fb ,_aga ,_agg ...);};

// NewConsoleLogger creates new console logger.
func NewConsoleLogger (logLevel LogLevel )*ConsoleLogger {return &ConsoleLogger {LogLevel :logLevel }};

// Warning logs warning message.
func (_ga WriterLogger )Warning (format string ,args ...interface{}){if _ga .LogLevel >=LogLevelWarning {_eac :="\u005b\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u005d\u0020";_ga .logToWriter (_ga .Output ,_eac ,format ,args ...);};};

// IsLogLevel returns true if log level is greater or equal than `level`.
// Can be used to avoid resource intensive calls to loggers.
func (_cag WriterLogger )IsLogLevel (level LogLevel )bool {return _cag .LogLevel >=level };

// Info logs info message.
func (_cbb WriterLogger )Info (format string ,args ...interface{}){if _cbb .LogLevel >=LogLevelInfo {_aa :="\u005bI\u004e\u0046\u004f\u005d\u0020";_cbb .logToWriter (_cbb .Output ,_aa ,format ,args ...);};};

// Trace does nothing for dummy logger.
func (DummyLogger )Trace (format string ,args ...interface{}){};

// Notice does nothing for dummy logger.
func (DummyLogger )Notice (format string ,args ...interface{}){};const _age =6;func (_gdc WriterLogger )logToWriter (_fa _dc .Writer ,_gdca string ,_fc string ,_bad ...interface{}){_cebc (_fa ,_gdca ,_fc ,_bad );};

// Warning logs warning message.
func (_fff ConsoleLogger )Warning (format string ,args ...interface{}){if _fff .LogLevel >=LogLevelWarning {_ag :="\u005b\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u005d\u0020";_fff .output (_d .Stdout ,_ag ,format ,args ...);};};const _acc =30;

// Error logs error message.
func (_gg WriterLogger )Error (format string ,args ...interface{}){if _gg .LogLevel >=LogLevelError {_af :="\u005b\u0045\u0052\u0052\u004f\u0052\u005d\u0020";_gg .logToWriter (_gg .Output ,_af ,format ,args ...);};};

// DummyLogger does nothing.
type DummyLogger struct{};var Log Logger =DummyLogger {};

// LogLevel is the verbosity level for logging.
type LogLevel int ;var ReleasedAt =_g .Date (_bd ,_gbb ,_age ,_db ,_acc ,0,0,_g .UTC );

// IsLogLevel returns true if log level is greater or equal than `level`.
// Can be used to avoid resource intensive calls to loggers.
func (_cbg ConsoleLogger )IsLogLevel (level LogLevel )bool {return _cbg .LogLevel >=level };const _db =15;

// Info logs info message.
func (_ec ConsoleLogger )Info (format string ,args ...interface{}){if _ec .LogLevel >=LogLevelInfo {_ca :="\u005bI\u004e\u0046\u004f\u005d\u0020";_ec .output (_d .Stdout ,_ca ,format ,args ...);};};

// Trace logs trace message.
func (_ad WriterLogger )Trace (format string ,args ...interface{}){if _ad .LogLevel >=LogLevelTrace {_afd :="\u005b\u0054\u0052\u0041\u0043\u0045\u005d\u0020";_ad .logToWriter (_ad .Output ,_afd ,format ,args ...);};};

// Error logs error message.
func (_df ConsoleLogger )Error (format string ,args ...interface{}){if _df .LogLevel >=LogLevelError {_a :="\u005b\u0045\u0052\u0052\u004f\u0052\u005d\u0020";_df .output (_d .Stdout ,_a ,format ,args ...);};};

// Debug logs debug message.
func (_ea ConsoleLogger )Debug (format string ,args ...interface{}){if _ea .LogLevel >=LogLevelDebug {_cae :="\u005b\u0044\u0045\u0042\u0055\u0047\u005d\u0020";_ea .output (_d .Stdout ,_cae ,format ,args ...);};};

// Notice logs notice message.
func (_afe WriterLogger )Notice (format string ,args ...interface{}){if _afe .LogLevel >=LogLevelNotice {_ae :="\u005bN\u004f\u0054\u0049\u0043\u0045\u005d ";_afe .logToWriter (_afe .Output ,_ae ,format ,args ...);};};const _bd =2025;

// Info does nothing for dummy logger.
func (DummyLogger )Info (format string ,args ...interface{}){};

// Trace logs trace message.
func (_gb ConsoleLogger )Trace (format string ,args ...interface{}){if _gb .LogLevel >=LogLevelTrace {_ee :="\u005b\u0054\u0052\u0041\u0043\u0045\u005d\u0020";_gb .output (_d .Stdout ,_ee ,format ,args ...);};};const Version ="\u0034\u002e\u0034.\u0030";
const (LogLevelTrace LogLevel =5;LogLevelDebug LogLevel =4;LogLevelInfo LogLevel =3;LogLevelNotice LogLevel =2;LogLevelWarning LogLevel =1;LogLevelError LogLevel =0;);const _ebfa ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";


// Warning does nothing for dummy logger.
func (DummyLogger )Warning (format string ,args ...interface{}){};

// Debug does nothing for dummy logger.
func (DummyLogger )Debug (format string ,args ...interface{}){};

// Error does nothing for dummy logger.
func (DummyLogger )Error (format string ,args ...interface{}){};

// NewWriterLogger creates new 'writer' logger.
func NewWriterLogger (logLevel LogLevel ,writer _dc .Writer )*WriterLogger {_cea :=WriterLogger {Output :writer ,LogLevel :logLevel };return &_cea ;};

// SetLogger sets 'logger' to be used by the unidoc unipdf library.
func SetLogger (logger Logger ){Log =logger };

// WriterLogger is the logger that writes data to the Output writer
type WriterLogger struct{LogLevel LogLevel ;Output _dc .Writer ;};

// IsLogLevel returns true from dummy logger.
func (DummyLogger )IsLogLevel (level LogLevel )bool {return true };

// Notice logs notice message.
func (_gcd ConsoleLogger )Notice (format string ,args ...interface{}){if _gcd .LogLevel >=LogLevelNotice {_cgc :="\u005bN\u004f\u0054\u0049\u0043\u0045\u005d ";_gcd .output (_d .Stdout ,_cgc ,format ,args ...);};};

// UtcTimeFormat returns a formatted string describing a UTC timestamp.
func UtcTimeFormat (t _g .Time )string {return t .Format (_ebfa )+"\u0020\u0055\u0054\u0043"};func (_ebf ConsoleLogger )output (_ceb _dc .Writer ,_gdb string ,_ab string ,_gdd ...interface{}){_cebc (_ceb ,_gdb ,_ab ,_gdd ...);};

// ConsoleLogger is a logger that writes logs to the 'os.Stdout'
type ConsoleLogger struct{LogLevel LogLevel ;};const _gbb =10;

// Debug logs debug message.
func (_gdf WriterLogger )Debug (format string ,args ...interface{}){if _gdf .LogLevel >=LogLevelDebug {_gae :="\u005b\u0044\u0045\u0042\u0055\u0047\u005d\u0020";_gdf .logToWriter (_gdf .Output ,_gae ,format ,args ...);};};