1+ //GoVector vector clock logging library
12package govec
23
34import (
@@ -15,29 +16,6 @@ import (
1516 "github.com/vmihailenco/msgpack"
1617)
1718
18- /*
19- - All licences like other licenses ...
20-
21- How to Use This Library
22-
23- Step 1:
24- Create a Global Variable and Initialize it using like this =
25-
26- Logger:= Initialize("MyProcess",ShouldYouSeeLoggingOnScreen,ShouldISendVectorClockonWire,Debug)
27-
28- Step 2:
29- When Ever You Decide to Send any []byte , before sending call PrepareSend like this:
30- SENDSLICE := PrepareSend("Message Description", YourPayload)
31- and send the SENDSLICE instead of your Designated Payload
32-
33- Step 3:
34- When Receiveing, AFTER you receive your message, pass the []byte into UnpackRecieve
35- like this:
36-
37- UnpackReceive("Message Description", []ReceivedPayload, *RETURNSLICE)
38- and use RETURNSLICE for further processing.
39- */
40-
4119var (
4220 logToTerminal = false
4321 _ msgpack.CustomEncoder = (* VClockPayload )(nil )
@@ -67,6 +45,7 @@ var colorLookup = [...]ct.Color{
6745 FATAL : ct .Magenta ,
6846}
6947
48+ //translates priority enums into strings
7049var prefixLookup = [... ]string {
7150 DEBUG : "DEBUG" ,
7251 INFO : "INFO" ,
@@ -213,7 +192,9 @@ func (d *VClockPayload) DecodeMsgpack(dec *msgpack.Decoder) error {
213192}
214193
215194//The GoLog struct provides an interface to creating and maintaining
216- //vector timestamp entries in the generated log file
195+ //vector timestamp entries in the generated log file. GoLogs are
196+ //initialized with Configs which control logger output, format, and
197+ //frequency.
217198type GoLog struct {
218199
219200 //Local Process ID
@@ -258,10 +239,9 @@ type GoLog struct {
258239 mutex sync.RWMutex
259240}
260241
261- //Returns a Go Log Struct taking in two arguments and truncates previous logs:
262- //MyProcessName (string): local process name; must be unique in your distributed system.
263- //LogFileName (string) : name of the log file that will store info. Any old log with the same name will be truncated
264- //Config (GoLogConfig) : config struct defining the values of the options of GoLog logger
242+ //InitGoVector returns a GoLog which generates a logs prefixed with
243+ //processid, to a file name logfilename.log. Any old log with the same
244+ //name will be trucated. Config controls logging options. See GoLogConfig for more details.
265245func InitGoVector (processid string , logfilename string , config GoLogConfig ) * GoLog {
266246
267247 gv := & GoLog {}
0 commit comments