encoder

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

* @Author: nijineko * @Date: 2025-06-10 21:56:37 * @LastEditTime: 2025-06-10 21:56:43 * @LastEditors: nijineko * @Description: noa encoder context package * @FilePath: \noa\encoder\context.go

* @Author: nijineko * @Date: 2025-06-10 21:23:29 * @LastEditTime: 2025-06-10 21:33:31 * @LastEditors: nijineko * @Description: noa encoder package * @FilePath: \noa\encoder\encoder.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Time   time.Time // Log time
	Level  int       // Log level
	Source string    // Log source
	Data   []any     // Datas

	ExtendKeys map[string]any // extend keys for custom data
}

encoder context struct

func NewContext

func NewContext(Time time.Time, Level int, Source string, Data []any) *Context

*

  • @description: Create a new encoder context
  • @param {int} Level log level
  • @param {string} Source log source
  • @param {[]any} Data data to log
  • @return {*Context} new encoder context

func (*Context) Get

func (c *Context) Get(Key string) any

*

  • @description: Get custom data from the encoder context
  • @param {string} Key
  • @return {any} Value

func (*Context) Set

func (c *Context) Set(Key string, Value any)

*

  • @description: Set custom data in the encoder context
  • @param {string} Key
  • @param {any} Value

type Encoder

type Encoder interface {
	/**
	* @description: print log data
	* @param {*Context} c encoder context
	 */
	Print(c *Context)
	/**
	* @description: Get file extension for the encoded file (Note: A file can only have one extension, such as .log. Having multiple extensions may cause parsing errors.)
	* @return {string} file extension
	 */
	WriteFileExtension() string
	/**
	* @description: Write data to file
	* @param {*os.File} FileHandle file handle
	* @param {*Context} c encoder context
	* @return {error} error
	 */
	Write(FileHandle *os.File, c *Context) error
}

Encoder interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL