Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
msg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Captain's Log

GoReportCard GoDoc Conventional Commits License: BSD-3

A simple logging library for Go

  • Colors
  • Multiple levels
  • Structured logging
  • Function name detection

Screenshot of captainslog in action

Installation

go get github.com/vincentfiestada/captainslog/v2

Usage

This library is designed to provide a familiar yet powerful interface for logging. Each logging method accepts a format string and arguments. Structured logging is supported right out of the box. The Logger allows you to turn colors on/off, specify a datetime format, set the logging threshold, and even provide your own function to control how logs are written.

package main

import (
	"github.com/vincentfiestada/captainslog/v2"
)

var log = captainslog.NewLogger()

func main() {

	log.Trace("this is %s", "captainslog")
	log.Debug("this is %s", "captainslog")
	log.Info("this is %s", "captainslog")
	log.Warn("this is %s", "captainslog")
	log.Error("this is %s", "captainslog")

	log.Fields(

		log.I("captain", "picard"),
		log.I("first officer", "riker"),
		log.I("science officer", "data"),
		log.I("medical officer", "crusher"),
		log.I("chief engineer", "la forge"),
		log.I("security officer", "worf"),

	).Info("starship enterprise")

}

Format

There are several log formats included that you can choose from. It's also easy to write your own custom function to print logs just the way you want to.

Performance

The main goals of this library are convenience and familiarity for programmers, but it should have reasonable performance for most projects. To see for yourself, run the benchmarks using Invoke-Benchmarks.

Development

Please read the Contribution Guide before you proceed. This project uses Powershell Core to run tasks. To get started,

Import-Module .\tasks.psm1
Get-Command -Module tasks

Copyright

Copyright 2019-2020 Vincent Fiestada. This project is released under a BSD-style license.

Icon made by Good Ware.

You can’t perform that action at this time.