Logger created in Golang. Runs as a separate goroutine.
Create a Loggit Object in your code, this will need to be a global variable so all functions can access it
var ThisLog *Logit.Logger
Logit accepts items that implement the "io.WriteCloser" to be valid Loggers. Included are funtions to Log to a File and the Terminal.
FileLog, err := Logit.OpenFile("/path/to/log/file")
TermLog := Logit.TermLog()
Somewhere in your code, you need to Start the Logging goroutine.
ThisLog, err = Logit.StartLogger(FileLog)
ThatLog, err = Logit.StartLogger(TermLog)
This will start a goroutine that has the file open.
Logit then uses Channels to push strings into this goroutine, writing them to the Log. Format a string to your liking, and simply pass it into the Log object that you created.
ThisLog.Log("string!")
Using the above will produce the following example output in the log:
09:15:15.918788110: string!
On shutdown of your application, you will want to run the "Quit" function on your Logit Object to ensure all is closed and the goroutines are stopped.
ThisLog.Quit()
ThatLog.Quit()
Able to handle concurrency. As long as your goroutine has access to a valid Logit Object, you are able to use the Log function safely. By pushing a string onto the channel, Logit will append it to the log when it can.
As of now if the log file is removed during runtime Logit will not complain, and all will continue to work without a hitch except logging. This is not ideal of course.
logit's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.