logging

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

README

Logger Implementation

File Logger is a lightweight asynchronous logging implementations. It logs messages to files with rotation and compression support. The code is designed to be easily extendible for other logging destinations, such as Sentry.io.

Features

- Asynchronous logging using goroutines and channels.
- Log file rotation based on file size.
- Compressed old log files to save disk space.
- Easily extendible for other logging destinations.

Usage

Import the Package

import (
    "github.com/chuxorg/filelogger"
)

Documentation

Overview

Author: Chuck Sailer Date: 2023-04-20 Description: This file contains the code for the CloudWatchLogger struct and its methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudWatchLogger

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

CloudWatchLogger is a logger that writes log messages to CloudWatch.

func NewCloudWatchLogger

func NewCloudWatchLogger(logGroupName, logStreamName string) (*CloudWatchLogger, error)

NewCloudWatchLogger creates a new CloudWatchLogger.

func (*CloudWatchLogger) Close

func (cwl *CloudWatchLogger) Close() error

Close stops the CloudWatch logger.

func (*CloudWatchLogger) Debug

func (cwl *CloudWatchLogger) Debug(msg string, args ...interface{})

Debug writes a debug log message to CloudWatch.

func (*CloudWatchLogger) Error

func (cwl *CloudWatchLogger) Error(msg string, args ...interface{})

Error writes an error log message to CloudWatch.

func (*CloudWatchLogger) Info

func (cwl *CloudWatchLogger) Info(msg string, args ...interface{})

Info writes an informational log message to CloudWatch.

func (*CloudWatchLogger) Warn

func (cwl *CloudWatchLogger) Warn(msg string, args ...interface{})

Warn writes a warning log message to CloudWatch.

type FileLogger

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

func NewFileLogger

func NewFileLogger(logDirectory, logFilePrefix string, maxFileSize int64) (*FileLogger, error)

func (*FileLogger) Close

func (fl *FileLogger) Close()

func (*FileLogger) Debug

func (fl *FileLogger) Debug(msg string, args ...interface{})

implement ILogger interface

func (*FileLogger) Error

func (fl *FileLogger) Error(msg string, args ...interface{})

func (*FileLogger) Info

func (fl *FileLogger) Info(msg string, args ...interface{})

func (*FileLogger) Warn

func (fl *FileLogger) Warn(msg string, args ...interface{})

type ILogger

type ILogger interface {
	// Debug logs a message at level Debug on the standard logger.
	Debug(msg string, args ...interface{})
	// Info logs a message at level Info on the standard logger.
	Info(msg string, args ...interface{})
	// Warn logs a message at level Warn on the standard logger.
	Warn(msg string, args ...interface{})
	// Error logs a message at level Error on the standard logger.
	Error(msg string, args ...interface{})
	// Close closes the logger.
	Close()
}

Logger is the interface that all loggers must implement.

type LogMessage

type LogMessage struct {
	LogGroupName  string // Name of the log group to write to
	LogStreamName string // Name of the log stream to write to
	Message       string // Log message to write
}

LogMessage is a struct that contains the information needed to write a log message to CloudWatch.

func NewLogMessage

func NewLogMessage(logGroupName, logStreamName, message string) LogMessage

NewLogMessage creates a new LogMessage struct.

Jump to

Keyboard shortcuts

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