// Generated by Lisette bindgen
// Source: log/slog (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.11

import "go:context"
import "go:io"
import "go:log"
import "go:time"

pub enum Kind: int {
  KindAny = 0,
  KindBool = 1,
  KindDuration = 2,
  KindFloat64 = 3,
  KindGroup = 8,
  KindInt64 = 4,
  KindLogValuer = 9,
  KindString = 5,
  KindTime = 6,
  KindUint64 = 7,
}

pub const KindAny: Kind = 0

pub const KindBool: Kind = 1

pub const KindDuration: Kind = 2

pub const KindFloat64: Kind = 3

pub const KindGroup: Kind = 8

pub const KindInt64: Kind = 4

pub const KindLogValuer: Kind = 9

pub const KindString: Kind = 5

pub const KindTime: Kind = 6

pub const KindUint64: Kind = 7

pub enum Level: int {
  LevelDebug = -4,
  LevelError = 8,
  LevelInfo = 0,
  LevelWarn = 4,
}

pub const LevelDebug: Level = -4

pub const LevelError: Level = 8

pub const LevelInfo: Level = 0

pub const LevelWarn: Level = 4

pub fn Any(key: string, value: Unknown) -> Attr

pub fn AnyValue(v: Unknown) -> Value

pub fn Bool(key: string, v: bool) -> Attr

pub fn BoolValue(v: bool) -> Value

/// Debug calls [Logger.Debug] on the default logger.
pub fn Debug(msg: string, args: VarArgs<Unknown>)

/// DebugContext calls [Logger.DebugContext] on the default logger.
pub fn DebugContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

pub fn Default() -> Ref<Logger>

pub fn Duration(key: string, v: time.Duration) -> Attr

pub fn DurationValue(v: time.Duration) -> Value

/// Error calls [Logger.Error] on the default logger.
pub fn Error(msg: string, args: VarArgs<Unknown>)

/// ErrorContext calls [Logger.ErrorContext] on the default logger.
pub fn ErrorContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

pub fn Float64(key: string, v: float64) -> Attr

pub fn Float64Value(v: float64) -> Value

pub fn Group(key: string, args: VarArgs<Unknown>) -> Attr

pub fn GroupAttrs(key: string, attrs: VarArgs<Attr>) -> Attr

pub fn GroupValue(as_: VarArgs<Attr>) -> Value

/// Info calls [Logger.Info] on the default logger.
pub fn Info(msg: string, args: VarArgs<Unknown>)

/// InfoContext calls [Logger.InfoContext] on the default logger.
pub fn InfoContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

pub fn Int(key: string, value: int) -> Attr

pub fn Int64(key: string, value: int64) -> Attr

pub fn Int64Value(v: int64) -> Value

pub fn IntValue(v: int) -> Value

/// Log calls [Logger.Log] on the default logger.
pub fn Log(
  ctx: context.Context,
  level: Level,
  msg: string,
  args: VarArgs<Unknown>,
)

/// LogAttrs calls [Logger.LogAttrs] on the default logger.
pub fn LogAttrs(
  ctx: context.Context,
  level: Level,
  msg: string,
  attrs: VarArgs<Attr>,
)

pub fn New(h: Handler) -> Ref<Logger>

pub fn NewJSONHandler(w: io.Writer, opts: Ref<HandlerOptions>) -> Ref<JSONHandler>

/// NewLogLogger returns a new [log.Logger] such that each call to its Output method
/// dispatches a Record to the specified handler. The logger acts as a bridge from
/// the older log API to newer structured logging handlers.
pub fn NewLogLogger(h: Handler, level: Level) -> Ref<log.Logger>

pub fn NewRecord(t: time.Time, level: Level, msg: string, pc: uint) -> Record

pub fn NewTextHandler(w: io.Writer, opts: Ref<HandlerOptions>) -> Ref<TextHandler>

/// SetDefault makes l the default [Logger], which is used by
/// the top-level functions [Info], [Debug] and so on.
/// After this call, output from the log package's default Logger
/// (as with [log.Print], etc.) will be logged using l's Handler,
/// at a level controlled by [SetLogLoggerLevel].
pub fn SetDefault(l: Ref<Logger>)

pub fn SetLogLoggerLevel(level: Level) -> Level

pub fn String(key: string, value: string) -> Attr

pub fn StringValue(value: string) -> Value

pub fn Time(key: string, v: time.Time) -> Attr

pub fn TimeValue(v: time.Time) -> Value

pub fn Uint64(key: string, v: uint64) -> Attr

pub fn Uint64Value(v: uint64) -> Value

/// Warn calls [Logger.Warn] on the default logger.
pub fn Warn(msg: string, args: VarArgs<Unknown>)

/// WarnContext calls [Logger.WarnContext] on the default logger.
pub fn WarnContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

pub fn With(args: VarArgs<Unknown>) -> Ref<Logger>

/// An Attr is a key-value pair.
pub struct Attr {
  pub Key: string,
  pub Value: Value,
}

/// A Handler handles log records produced by a Logger.
/// 
/// A typical handler may print log records to standard error,
/// or write them to a file or database, or perhaps augment them
/// with additional attributes and pass them on to another handler.
/// 
/// Any of the Handler's methods may be called concurrently with itself
/// or with other methods. It is the responsibility of the Handler to
/// manage this concurrency.
/// 
/// Users of the slog package should not invoke Handler methods directly.
/// They should use the methods of [Logger] instead.
/// 
/// Before implementing your own handler, consult https://go.dev/s/slog-handler-guide.
pub interface Handler {
  fn Enabled(arg0: context.Context, arg1: Level) -> bool
  fn Handle(arg0: context.Context, arg1: Record) -> Result<(), error>
  fn WithAttrs(attrs: Slice<Attr>) -> Handler
  fn WithGroup(name: string) -> Handler
}

/// HandlerOptions are options for a [TextHandler] or [JSONHandler].
/// A zero HandlerOptions consists entirely of default values.
pub struct HandlerOptions {
  pub AddSource: bool,
  pub Level: Option<Leveler>,
  pub ReplaceAttr: fn(Slice<string>, Attr) -> Attr,
}

/// JSONHandler is a [Handler] that writes Records to an [io.Writer] as
/// line-delimited JSON objects.
pub type JSONHandler

/// A LevelVar is a [Level] variable, to allow a [Handler] level to change
/// dynamically.
/// It implements [Leveler] as well as a Set method,
/// and it is safe for use by multiple goroutines.
/// The zero LevelVar corresponds to [LevelInfo].
pub type LevelVar

/// A Leveler provides a [Level] value.
/// 
/// As Level itself implements Leveler, clients typically supply
/// a Level value wherever a Leveler is needed, such as in [HandlerOptions].
/// Clients who need to vary the level dynamically can provide a more complex
/// Leveler implementation such as *[LevelVar].
pub interface Leveler {
  fn Level() -> Level
}

/// A LogValuer is any Go value that can convert itself into a Value for logging.
/// 
/// This mechanism may be used to defer expensive operations until they are
/// needed, or to expand a single value into a sequence of components.
pub interface LogValuer {
  fn LogValue() -> Value
}

/// A Logger records structured information about each call to its
/// Log, Debug, Info, Warn, and Error methods.
/// For each call, it creates a [Record] and passes it to a [Handler].
/// 
/// To create a new Logger, call [New] or a Logger method
/// that begins "With".
pub type Logger

/// A Record holds information about a log event.
/// Copies of a Record share state.
/// Do not modify a Record after handing out a copy to it.
/// Call [NewRecord] to create a new Record.
/// Use [Record.Clone] to create a copy with no shared state.
pub struct Record {
  pub Time: time.Time,
  pub Message: string,
  pub Level: Level,
  pub PC: uint,
}

/// Source describes the location of a line of source code.
pub struct Source {
  pub Function: string,
  pub File: string,
  pub Line: int,
}

/// TextHandler is a [Handler] that writes Records to an [io.Writer] as a
/// sequence of key=value pairs separated by spaces and followed by a newline.
pub type TextHandler

/// A Value can represent any Go value, but unlike type any,
/// it can represent most small values without an allocation.
/// The zero Value corresponds to nil.
pub type Value

/// Keys for "built-in" attributes.
const LevelKey = "level"

/// Keys for "built-in" attributes.
const MessageKey = "msg"

/// Keys for "built-in" attributes.
const SourceKey = "source"

/// Keys for "built-in" attributes.
const TimeKey = "time"

pub var DiscardHandler: Handler

impl Attr {
  /// Equal reports whether a and b have equal keys and values.
  fn Equal(self, b: Attr) -> bool

  fn String(self) -> string
}

impl JSONHandler {
  /// Enabled reports whether the handler handles records at the given level.
  /// The handler ignores records whose level is lower.
  fn Enabled(self: Ref<JSONHandler>, _: context.Context, level: Level) -> bool

  /// Handle formats its argument [Record] as a JSON object on a single line.
  /// 
  /// If the Record's time is zero, the time is omitted.
  /// Otherwise, the key is "time"
  /// and the value is output as with json.Marshal.
  /// 
  /// The level's key is "level" and its value is the result of calling [Level.String].
  /// 
  /// If the AddSource option is set and source information is available,
  /// the key is "source", and the value is a record of type [Source].
  /// 
  /// The message's key is "msg".
  /// 
  /// To modify these or other attributes, or remove them from the output, use
  /// [HandlerOptions.ReplaceAttr].
  /// 
  /// Values are formatted as with an [encoding/json.Encoder] with SetEscapeHTML(false),
  /// with two exceptions.
  /// 
  /// First, an Attr whose Value is of type error is formatted as a string, by
  /// calling its Error method. Only errors in Attrs receive this special treatment,
  /// not errors embedded in structs, slices, maps or other data structures that
  /// are processed by the [encoding/json] package.
  /// 
  /// Second, an encoding failure does not cause Handle to return an error.
  /// Instead, the error message is formatted as a string.
  /// 
  /// Each call to Handle results in a single serialized call to io.Writer.Write.
  fn Handle(self: Ref<JSONHandler>, _: context.Context, r: Record) -> Result<(), error>

  /// WithAttrs returns a new [JSONHandler] whose attributes consists
  /// of h's attributes followed by attrs.
  fn WithAttrs(self: Ref<JSONHandler>, attrs: Slice<Attr>) -> Handler

  fn WithGroup(self: Ref<JSONHandler>, name: string) -> Handler
}

impl Kind {
  fn String(self) -> string
}

impl Level {
  /// AppendText implements [encoding.TextAppender]
  /// by calling [Level.String].
  fn AppendText(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// Level returns the receiver.
  /// It implements [Leveler].
  fn Level(self) -> Level

  /// MarshalJSON implements [encoding/json.Marshaler]
  /// by quoting the output of [Level.String].
  fn MarshalJSON(self) -> Result<Slice<uint8>, error>

  /// MarshalText implements [encoding.TextMarshaler]
  /// by calling [Level.AppendText].
  fn MarshalText(self) -> Result<Slice<uint8>, error>

  /// String returns a name for the level.
  /// If the level has a name, then that name
  /// in uppercase is returned.
  /// If the level is between named values, then
  /// an integer is appended to the uppercased name.
  /// Examples:
  /// 
  /// 	LevelWarn.String() => "WARN"
  /// 	(LevelInfo+2).String() => "INFO+2"
  fn String(self) -> string

  /// UnmarshalJSON implements [encoding/json.Unmarshaler]
  /// It accepts any string produced by [Level.MarshalJSON],
  /// ignoring case.
  /// It also accepts numeric offsets that would result in a different string on
  /// output. For example, "Error-8" would marshal as "INFO".
  fn UnmarshalJSON(self: Ref<Level>, data: Slice<uint8>) -> Result<(), error>

  /// UnmarshalText implements [encoding.TextUnmarshaler].
  /// It accepts any string produced by [Level.MarshalText],
  /// ignoring case.
  /// It also accepts numeric offsets that would result in a different string on
  /// output. For example, "Error-8" would marshal as "INFO".
  fn UnmarshalText(self: Ref<Level>, data: Slice<uint8>) -> Result<(), error>
}

impl LevelVar {
  /// AppendText implements [encoding.TextAppender]
  /// by calling [Level.AppendText].
  fn AppendText(self: Ref<LevelVar>, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// Level returns v's level.
  fn Level(self: Ref<LevelVar>) -> Level

  /// MarshalText implements [encoding.TextMarshaler]
  /// by calling [LevelVar.AppendText].
  fn MarshalText(self: Ref<LevelVar>) -> Result<Slice<uint8>, error>

  /// Set sets v's level to l.
  fn Set(self: Ref<LevelVar>, l: Level)

  fn String(self: Ref<LevelVar>) -> string

  /// UnmarshalText implements [encoding.TextUnmarshaler]
  /// by calling [Level.UnmarshalText].
  fn UnmarshalText(self: Ref<LevelVar>, data: Slice<uint8>) -> Result<(), error>
}

impl Logger {
  /// Debug logs at [LevelDebug].
  fn Debug(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// DebugContext logs at [LevelDebug] with the given context.
  fn DebugContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// Enabled reports whether l emits log records at the given context and level.
  fn Enabled(self: Ref<Logger>, ctx: context.Context, level: Level) -> bool

  /// Error logs at [LevelError].
  fn Error(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// ErrorContext logs at [LevelError] with the given context.
  fn ErrorContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// Handler returns l's Handler.
  fn Handler(self: Ref<Logger>) -> Handler

  /// Info logs at [LevelInfo].
  fn Info(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// InfoContext logs at [LevelInfo] with the given context.
  fn InfoContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// Log emits a log record with the current time and the given level and message.
  /// The Record's Attrs consist of the Logger's attributes followed by
  /// the Attrs specified by args.
  /// 
  /// The attribute arguments are processed as follows:
  ///   - If an argument is an Attr, it is used as is.
  ///   - If an argument is a string and this is not the last argument,
  ///     the following argument is treated as the value and the two are combined
  ///     into an Attr.
  ///   - Otherwise, the argument is treated as a value with key "!BADKEY".
  fn Log(
    self: Ref<Logger>,
    ctx: context.Context,
    level: Level,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// LogAttrs is a more efficient version of [Logger.Log] that accepts only Attrs.
  fn LogAttrs(
    self: Ref<Logger>,
    ctx: context.Context,
    level: Level,
    msg: string,
    attrs: VarArgs<Attr>,
  )

  /// Warn logs at [LevelWarn].
  fn Warn(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// WarnContext logs at [LevelWarn] with the given context.
  fn WarnContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// With returns a Logger that includes the given attributes
  /// in each output operation. Arguments are converted to
  /// attributes as if by [Logger.Log].
  fn With(self: Ref<Logger>, args: VarArgs<Unknown>) -> Ref<Logger>

  /// WithGroup returns a Logger that starts a group, if name is non-empty.
  /// The keys of all attributes added to the Logger will be qualified by the given
  /// name. (How that qualification happens depends on the [Handler.WithGroup]
  /// method of the Logger's Handler.)
  /// 
  /// If name is empty, WithGroup returns the receiver.
  fn WithGroup(self: Ref<Logger>, name: string) -> Ref<Logger>
}

impl Record {
  /// Add converts the args to Attrs as described in [Logger.Log],
  /// then appends the Attrs to the [Record]'s list of Attrs.
  /// It omits empty groups.
  fn Add(self: Ref<Record>, args: VarArgs<Unknown>)

  /// AddAttrs appends the given Attrs to the [Record]'s list of Attrs.
  /// It omits empty groups.
  fn AddAttrs(self: Ref<Record>, attrs: VarArgs<Attr>)

  /// Attrs calls f on each Attr in the [Record].
  /// Iteration stops if f returns false.
  fn Attrs(self, f: fn(Attr) -> bool)

  /// Clone returns a copy of the record with no shared state.
  /// The original record and the clone can both be modified
  /// without interfering with each other.
  fn Clone(self) -> Record

  /// NumAttrs returns the number of attributes in the [Record].
  fn NumAttrs(self) -> int

  /// Source returns a new Source for the log event using r's PC.
  /// If the PC field is zero, meaning the Record was created without the necessary information
  /// or the location is unavailable, then nil is returned.
  fn Source(self) -> Option<Ref<Source>>
}

impl TextHandler {
  /// Enabled reports whether the handler handles records at the given level.
  /// The handler ignores records whose level is lower.
  fn Enabled(self: Ref<TextHandler>, _: context.Context, level: Level) -> bool

  /// Handle formats its argument [Record] as a single line of space-separated
  /// key=value items.
  /// 
  /// If the Record's time is zero, the time is omitted.
  /// Otherwise, the key is "time"
  /// and the value is output in RFC3339 format with millisecond precision.
  /// 
  /// The level's key is "level" and its value is the result of calling [Level.String].
  /// 
  /// If the AddSource option is set and source information is available,
  /// the key is "source" and the value is output as FILE:LINE.
  /// 
  /// The message's key is "msg".
  /// 
  /// To modify these or other attributes, or remove them from the output, use
  /// [HandlerOptions.ReplaceAttr].
  /// 
  /// If a value implements [encoding.TextMarshaler], the result of MarshalText is
  /// written. Otherwise, the result of [fmt.Sprint] is written.
  /// 
  /// Keys and values are quoted with [strconv.Quote] if they contain Unicode space
  /// characters, non-printing characters, '"' or '='.
  /// 
  /// Keys inside groups consist of components (keys or group names) separated by
  /// dots. No further escaping is performed.
  /// Thus there is no way to determine from the key "a.b.c" whether there
  /// are two groups "a" and "b" and a key "c", or a single group "a.b" and a key "c",
  /// or single group "a" and a key "b.c".
  /// If it is necessary to reconstruct the group structure of a key
  /// even in the presence of dots inside components, use
  /// [HandlerOptions.ReplaceAttr] to encode that information in the key.
  /// 
  /// Each call to Handle results in a single serialized call to
  /// io.Writer.Write.
  fn Handle(self: Ref<TextHandler>, _: context.Context, r: Record) -> Result<(), error>

  /// WithAttrs returns a new [TextHandler] whose attributes consists
  /// of h's attributes followed by attrs.
  fn WithAttrs(self: Ref<TextHandler>, attrs: Slice<Attr>) -> Handler

  fn WithGroup(self: Ref<TextHandler>, name: string) -> Handler
}

impl Value {
  /// Any returns v's value as an any.
  fn Any(self) -> Unknown

  /// Bool returns v's value as a bool. It panics
  /// if v is not a bool.
  fn Bool(self) -> bool

  /// Duration returns v's value as a [time.Duration]. It panics
  /// if v is not a time.Duration.
  fn Duration(self) -> time.Duration

  /// Equal reports whether v and w represent the same Go value.
  fn Equal(self, w: Value) -> bool

  /// Float64 returns v's value as a float64. It panics
  /// if v is not a float64.
  fn Float64(self) -> float64

  /// Group returns v's value as a []Attr.
  /// It panics if v's [Kind] is not [KindGroup].
  fn Group(self) -> Slice<Attr>

  /// Int64 returns v's value as an int64. It panics
  /// if v is not a signed integer.
  fn Int64(self) -> int64

  /// Kind returns v's Kind.
  fn Kind(self) -> Kind

  /// LogValuer returns v's value as a LogValuer. It panics
  /// if v is not a LogValuer.
  fn LogValuer(self) -> LogValuer

  /// Resolve repeatedly calls LogValue on v while it implements [LogValuer],
  /// and returns the result.
  /// If v resolves to a group, the group's attributes' values are not recursively
  /// resolved.
  /// If the number of LogValue calls exceeds a threshold, a Value containing an
  /// error is returned.
  /// Resolve's return value is guaranteed not to be of Kind [KindLogValuer].
  fn Resolve(self) -> Value

  /// String returns Value's value as a string, formatted like [fmt.Sprint]. Unlike
  /// the methods Int64, Float64, and so on, which panic if v is of the
  /// wrong kind, String never panics.
  fn String(self) -> string

  /// Time returns v's value as a [time.Time]. It panics
  /// if v is not a time.Time.
  fn Time(self) -> time.Time

  /// Uint64 returns v's value as a uint64. It panics
  /// if v is not an unsigned integer.
  fn Uint64(self) -> uint64
}
