ul

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: BSD-2-Clause Imports: 3 Imported by: 0

README

Go Reference

Install

go get github.com/aletheia7/ul
go test -v
  • Requires OSX Xcode compiler
  • Supports macOS os_log subsystem/category logging
  • Implements io.Writer and can be used with the go log package

Example

package main

import (
	"github.com/aletheia7/ul"
	"log"
)

func main() {
	l := ul.New()
	l.Log("Hello")

	// To see subsystem/category messages:
	// # log stream --level debug --predicate 'subsystem == "com.example.myapp"'
	// Filtering the log data using "subsystem == "com.example.myapp""
	// Timestamp                       Thread     Type        Activity             PID
	// 2017-09-07 17:17:01.680996-0700 0x20870    Default     0x0                  1842   t: [com.example.myapp.whatever] hi

	lo := ul.New_object("com.example.myapp", "whatever")
	// Must call Release() for subsystem/category logger only
	defer lo.Release()
	lo.Log("hi")
	
	// golang log package

	mylogger := log.New(lo, "stuff ", log.Lshortfile|log.Ltime)
	mylogger.Println("wow") 
}

License

Use of this source code is governed by a BSD-2-Clause license that can be found in the LICENSE file.

BSD-2-Clause License

Documentation

Index

Constants

View Source
const (
	Default level = iota
	Info
	Debug
	Error
	Fault
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	Subsystem string
	Category  string
	// io.Writer Default level
	Level level
	// contains filtered or unexported fields
}

func New

func New() *Logger

func New_object

func New_object(subsystem, category string) *Logger

Must call Release() to free subsystem/category

func (*Logger) Debug

func (o *Logger) Debug(s string)

limit: 256

func (*Logger) Debugf

func (o *Logger) Debugf(format string, a ...interface{})

limit: 256

func (*Logger) Error

func (o *Logger) Error(s string)

limit: 256

func (*Logger) Errorf

func (o *Logger) Errorf(format string, a ...interface{})

limit: 256

func (*Logger) Fault

func (o *Logger) Fault(s string)

limit: 256

func (*Logger) Faultf

func (o *Logger) Faultf(format string, a ...interface{})

limit: 256

func (*Logger) Info

func (o *Logger) Info(s string)

limit: 256

func (*Logger) Infof

func (o *Logger) Infof(format string, a ...interface{})

limit: 256

func (*Logger) Log

func (o *Logger) Log(s string)

limit: 1024

func (*Logger) Logf

func (o *Logger) Logf(format string, a ...interface{})

limit: 1024

func (*Logger) Release

func (o *Logger) Release()

func (*Logger) Write

func (o *Logger) Write(p []byte) (n int, err error)

Satifies io.Writer. Can be used with the log package. Set Logger.Level for the default level log.SetOutput(*ul.Logger)

Jump to

Keyboard shortcuts

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