parent
88226e0679
commit
5701f591c4
@ -0,0 +1,41 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package values
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Field interface {
|
||||
Namer
|
||||
Valuer
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
func NewField (name string, value any) (Field,error) {
|
||||
switch value.(type) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_string.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
package values
|
||||
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
|
||||
FieldString struct {
|
||||
n string
|
||||
v string
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
func NewFieldString (name string, value string) *FieldString {
|
||||
return &FieldString {
|
||||
n : name,
|
||||
v: value,
|
||||
}
|
||||
}
|
||||
|
||||
func (f FieldString) Name () string {
|
||||
return f.n }
|
||||
|
||||
func (f FieldString) Value() string {
|
||||
return f.v }
|
||||
|
||||
func (_ FieldString) FieldType () FieldType {
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_type.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package values
|
||||
|
||||
const (
|
||||
|
||||
FieldTypeUnknown FieldType = iota
|
||||
FieldTypeString
|
||||
FieldTypeInt8
|
||||
FieldTypeInt16
|
||||
FieldTypeInt32
|
||||
FieldTypeInt64
|
||||
FieldTypeUInt8
|
||||
FieldTypeUInt16
|
||||
FieldTypeUInt32
|
||||
FieldTypeUInt64
|
||||
FieldTypeFloat32
|
||||
FieldTypeFloat64
|
||||
|
||||
)
|
||||
|
||||
type FieldType uint8
|
||||
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name namer.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package values
|
||||
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Namer interface {
|
||||
Name () string
|
||||
}
|
||||
|
||||
|
||||
NameFnc func () string
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (f NameFnc) Name () string {
|
||||
return f() }
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name valueSetter.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package values
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
|
||||
ValueSetter interface {
|
||||
SetValue (value any) error
|
||||
}
|
||||
|
||||
|
||||
SetValueFnc func (value any) error
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (f SetValueFnc) SetValue (value any) error {
|
||||
return f(value) }
|
||||
|
||||
@ -0,0 +1,127 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name entry_fortmats.go
|
||||
// Created by DEV
|
||||
// Modified 23/02/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"activething.com/go/gogo/core/bins"
|
||||
"activething.com/go/gogo/core/times"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
EntryFormatter interface {
|
||||
FormatEntry (buffer *bins.Buffer, entry *Entry)
|
||||
}
|
||||
|
||||
|
||||
FormatEntryFnc func(buffer *bins.Buffer, entry *Entry)
|
||||
|
||||
)
|
||||
|
||||
|
||||
func (f FormatEntryFnc) FormatEntry (buffer *bins.Buffer, entry *Entry) {
|
||||
f(buffer,entry) }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func EntryFormatTextShort(buffer *bins.Buffer, entry *Entry){
|
||||
buffer.WriteString(entry.Level.String())
|
||||
buffer.WriteByte(' ')
|
||||
buffer.WriteString(entry.Logger.Name())
|
||||
buffer.WriteByte(' ')
|
||||
buffer.AppendWith(bins.AppendFnc(func (d []byte) []byte { return times.TimeANSIC(entry.Date,d) }))
|
||||
buffer.WriteByte(' ')
|
||||
buffer.WriteString(entry.Message)
|
||||
if entry.Err != nil {
|
||||
buffer.WriteString(" Error: ")
|
||||
buffer.WriteString(entry.Err.Error())
|
||||
}
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
|
||||
|
||||
func EntryFormatTextLong(buffer *bins.Buffer, entry *Entry) {
|
||||
buffer.WriteString(entry.Level.String())
|
||||
|
||||
buffer.Write2Byte(' ','(')
|
||||
buffer.WriteUint64(entry.Id,nil)
|
||||
buffer.Write2Byte(')',' ')
|
||||
|
||||
buffer.Write2Byte('>',' ')
|
||||
buffer.WriteString(entry.Logger.Name())
|
||||
buffer.Write2Byte(':',' ')
|
||||
buffer.WriteString(entry.Message)
|
||||
buffer.WriteByte('\n')
|
||||
|
||||
buffer.WriteString("\tDate: ")
|
||||
buffer.AppendWith(bins.AppendFnc(func (d []byte) []byte { return times.TimeANSIC(entry.Date,d) }))
|
||||
buffer.WriteByte('\n')
|
||||
|
||||
if entry.Err != nil {
|
||||
buffer.WriteString("\tError: ")
|
||||
buffer.WriteString(entry.Err.Error())
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
if entry.Scope != "" {
|
||||
buffer.WriteString("\tScope: ")
|
||||
buffer.WriteString(entry.Scope)
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
/*
|
||||
if len(entry.Fields) > 0 {
|
||||
buffer.WriteString("\tFields\n")
|
||||
for _, f := range entry.Fields {
|
||||
buffer.Write2Byte('\t','\t')
|
||||
buffer.WriteString(f.Name())
|
||||
buffer.Write2Byte(':', ' ')
|
||||
buffer.WriteString(fmt.Sprintf("%v", f.Value()))
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
}
|
||||
|
||||
if len(entry.Stack) > 0 {
|
||||
buffer.WriteString("\tCaller\n")
|
||||
buffer.WriteString("\t\tName: ")
|
||||
buffer.WriteString(entry.Stack[0].Name())
|
||||
buffer.WriteString("\n\t\tLine: ")
|
||||
buffer.WriteInt(entry.Frame.Line())
|
||||
buffer.WriteString("\n\t\tFile: ")
|
||||
buffer.WriteString(entry.Frame.File())
|
||||
buffer.WriteString("\n\t\tPackage: ")
|
||||
buffer.WriteString(entry.Frame.Package())
|
||||
if sc,er := entry.Frame.SourceLine(); er == nil {
|
||||
buffer.WriteString("\n\t\tSource : ")
|
||||
buffer.WriteString(sc)
|
||||
}
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name entry_logger.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
EntryLogger interface {
|
||||
|
||||
Log (entry *Entry) error
|
||||
}
|
||||
|
||||
LogEntry func (entry *Entry) error
|
||||
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name logger_core.go
|
||||
// Created by DEV
|
||||
// Modified 03/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
|
||||
LoggerCore struct {
|
||||
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,64 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name queue.go
|
||||
// Created by DEV
|
||||
// Modified 23/02/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
entryQueue []*Entry
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (q entryQueue) Len() int {
|
||||
return len(q) }
|
||||
|
||||
|
||||
|
||||
func (q *entryQueue) PushNew (logger Logger, level Level, message string, err error, options ...EntryFnc){
|
||||
*q = append(*q,NewEntry(logger, level, message,err,options ...)) }
|
||||
|
||||
|
||||
|
||||
func (q *entryQueue) Push(ent *Entry){
|
||||
*q = append(*q,ent) }
|
||||
|
||||
|
||||
func (q *entryQueue) Pop () *Entry {
|
||||
if len(*q) == 0 {
|
||||
return nil
|
||||
}
|
||||
en := (*q)[0]
|
||||
*q = (*q)[1:]
|
||||
return en
|
||||
}
|
||||
|
||||
|
||||
func (q *entryQueue) Clear(){
|
||||
for en := q.Pop(); en != nil; {
|
||||
G.entryPool.Put(en)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue