Socket
Book a DemoInstallSign in
Socket

monis.app/mlog

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monis.app/mlog

Go Modules
Version
v0.0.4
Version published
Created
Source

mlog is an opinionated structured log package for Kubernetes devs who are stuck using klog.

Go Reference

package main

import "monis.app/mlog"

func main() {
	if err := mainErr(); err != nil {
		mlog.Fatal(err)
	}
}

func mainErr() error { // return an error instead of mlog.Fatal to allow defer statements to run
	defer mlog.Setup()()  // set up log flushing and attempt to flush on exit

	// use Always for logs emitted before config parsing
	mlog.Always("Running server", "version", version)

	// set up ctx and logConfig

	if err := mlog.ValidateAndSetLogLevelAndFormatGlobally(ctx, logConfig); err != nil {
		return fmt.Errorf("validate log level: %w", err)
	}

	// run server
}

FAQs

Package last updated on 02 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts