evtlog

package
v0.0.59 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: Apache-2.0, Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package evtlog provides access to the Windows Event Log.

Index

Constants

View Source
const MaxMsgSize = 31839

MaxMsgSize is the max size of a UTF-16 formatted Event Log message

Variables

This section is empty.

Functions

func BytesToUTF16

func BytesToUTF16(b []byte) ([]uint16, error)

BytesToUTF16 converts byte slice b to UTF-16.

func EventIsRegistered

func EventIsRegistered(src string) (bool, error)

EventIsRegistered returns if source src is registered with the Application Event Log.

func Install

func Install(src string) error

Install modifies PC registry to allow logging with an event source src, if it does not already exist. It adds all required keys and values to the event log registry key.

func Remove

func Remove(src string) error

Remove deletes all registry elements installed by the correspondent Install.

Types

type EventType

type EventType uint16

EventType is a Event Log event type

func (EventType) EventID

func (e EventType) EventID() uint32

EventID returns the EventID corresponding to the EventType, these values were arbitrarily determined.

ErrorType       = 1
WarningType     = 1 << 1 // 2
InformationType = 1 << 2 // 4

type LogWriter

type LogWriter struct {
	Handle    windows.Handle
	EventType EventType
	EventID   uint32 // derived from EventType
}

LogWriter is a Writer for writing messages to the event log.

func OpenWriter

func OpenWriter(etype EventType, source string) (*LogWriter, error)

OpenWriter retrieves a handle to the specified event log.

func (*LogWriter) Close

func (l *LogWriter) Close() error

Close closes event log l.

func (*LogWriter) Write

func (l *LogWriter) Write(b []byte) (int, error)

Write writes UTF-8 encoded byte slice b to the Event Log, before writing b is converted to UTF-16 and thus must be ASCII or UTF-8 encoded. If the encoded length of b is greater than MaxMsgSize, b is truncated.

Jump to

Keyboard shortcuts

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