diff --git a/LICENCE b/LICENCE new file mode 100644 index 00000000..3e87da9a --- /dev/null +++ b/LICENCE @@ -0,0 +1,11 @@ +Copyright 2022 Sam Therapy, Gregward Bulon + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/awl.go b/awl.go index 3f3242a4..6c5af9c2 100644 --- a/awl.go +++ b/awl.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package main import ( diff --git a/cli.go b/cli.go index 5fee5529..60c4b7b8 100644 --- a/cli.go +++ b/cli.go @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-3-Clause package main import ( diff --git a/cli_test.go b/cli_test.go index e621e631..c22ca487 100644 --- a/cli_test.go +++ b/cli_test.go @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-3-Clause package main import ( diff --git a/go.mod b/go.mod index c863eb86..94b74a22 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect - golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect + golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/tools v0.1.11 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect diff --git a/go.sum b/go.sum index 8615db15..c9926fb7 100644 --- a/go.sum +++ b/go.sum @@ -235,8 +235,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU= -golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= +golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/logawl/docs.go b/logawl/docs.go new file mode 100644 index 00000000..b67c5ea9 --- /dev/null +++ b/logawl/docs.go @@ -0,0 +1,30 @@ +/* +LogAwl is a package for custom logging needs + +LogAwl extends the standard log library with support for log levels +This is _different_ from the syslog package in the standard library because you do not define a file +because awl is a cli utility it writes directly to std err. +*/ +// Use the New() function to init logawl +// +// logger := logawl.New() +// +// You can call specific logging levels from your new logger using +// +// logger.Debug("Message to log") +// logger.Fatal("Message to log") +// logger.Info("Message to log") +// logger.Error("Message to log") +// +// You may also set the log level on the fly with +// +// Logger.SetLevel(3) +// This allows you to change the default level (Info) and prevent log messages from being posted at higher verbosity levels +//for example if +// Logger.SetLevel(3) +// is not called and you call +// Logger.Debug() +// this runs through +// IsLevel(level) +// to verify if the debug log should be sent to std.Err or not based on the current expected log level +package logawl diff --git a/logawl/logawl.go b/logawl/logawl.go index 27e8e586..f5c996ee 100644 --- a/logawl/logawl.go +++ b/logawl/logawl.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package logawl import ( diff --git a/logawl/logger.go b/logawl/logger.go index 311de27c..09f711fa 100644 --- a/logawl/logger.go +++ b/logawl/logger.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package logawl import ( @@ -62,6 +64,9 @@ func (l *Logger) formatHeader(buf *[]byte, t time.Time, line int, level Level) { *buf = append(*buf, ']') *buf = append(*buf, ':') *buf = append(*buf, ' ') + } else { + fmt.Printf("Unable to unmarshal log level: %v", err) + os.Exit(2) //Fucking kill him } } diff --git a/query.go b/query.go index a84ff6c7..678c55d7 100644 --- a/query.go +++ b/query.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package main import ( diff --git a/query/HTTPS.go b/query/HTTPS.go index 83890609..8eaec04c 100644 --- a/query/HTTPS.go +++ b/query/HTTPS.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package query import ( diff --git a/query/QUIC.go b/query/QUIC.go index fda54650..43ca6584 100644 --- a/query/QUIC.go +++ b/query/QUIC.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package query import ( diff --git a/util/helpers.go b/util/helpers.go index cb059b82..814bcb6d 100644 --- a/util/helpers.go +++ b/util/helpers.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package util import ( diff --git a/util/helpers_test.go b/util/helpers_test.go index 0d0b6e5b..c1aab946 100644 --- a/util/helpers_test.go +++ b/util/helpers_test.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: BSD-3-Clause + package util import (