logtofile

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 4 Imported by: 4

README

Log to file Go Reference

Save your logs to a file to keep track of your project.

Installation

You can use the go tool to install logtofile:

go get github.com/Mydao57/logtofile

Usage

In your Go app you can call the logger like this:

package main

import (
	"log"
	"github.com/Mydao57/logtofile"
)

func init() {
	err := logger.NewLogger("./logs")
	if err != nil {
		log.Fatalf("could not create logger: %v", err)
	}
}

func main() {
	defer logger.Close()

	logger.INFO("This is an info message from main")
}

Contributing

Contributions are welcome. Don’t hesitate to make a PR of your features

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close the log file

func DEBUG

func DEBUG(message string)

DEBUG logs a debug message to the log file.

func ERROR

func ERROR(message string)

ERROR logs an error message to the log file.

func FATAL

func FATAL(message string)

FATAL logs a fatal error message to the log file.

func INFO

func INFO(message string)

INFO logs an information message to the log file.

func NewLogger

func NewLogger(directory string) error

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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