<commit_before># serverlog
A thread safe logging system wit colours for servers. Thread safe for writing the log to a file

## Import
Go get the package like this
```
go get github.com/canopener/serverlog
```
Import like this
```
import "github.com/canopener/serverlog"
```

## Usage
The package needs to be initialized. Use the Init function for this.

Set the first parameter to true to enable logging to the console.

Set the second Parameter to true to enable logging to a file.

If the second parameter is set to true the third parameter needs to be the path to the logfile(doesnt have to exist, if exists will append)

```
serverlog.Init(true, true, "/home/mladen/logs/myserver.log")
```

3 logging functions are available.
```
serverlog.Startup("server listening on port:", PORT) // for startup logging
<commit_msg>Readme updated, need new pictures.<commit_after>Server Log v1.2.0
=================
A thread safe logging system for servers. Serverlog can log to files and to the console(with pretty colours) depending on what you specify. Logfiles will be separated by dates and can also manage how many logfiles you want on the server at any one time.

## Import
Go get the package like this
```
go get github.com/canopener/serverlog
```
Import like this
```
import "github.com/canopener/serverlog"
```

## Usage
The package needs to be initialized. Use the Init function for this.

1. Set the first parameter to true to enable logging to the console.

2. Set the second Parameter to true to enable logging to a file.

3. The third parameter represents the maximum amount of logfiles you wish to have at any one time. the logfiles are separated by days e.g "20-12-2015.csrv.log", "21-12-2015.csrv.log" etc.. Set to anything less than 1 if you want there to be no limit. The oldest logfiles will be deleted as new ones are created in order have only the amount of logfiles you specify here in the directory at any one time.

4. The fourth parameter is the path to the directory in wich you wish to store the logfiles. You need to have read and write permissions to the directory in order for Serverlog to work. Serverlog needs to delete old logfiles to make sure that the third parameter is satisfied so make sure you dont put anything of value within this directory as it has a chance of being deleted

Note: if the second parameter is set to false the third and fourth can be random as they wont even be evaluated by serverlog.

```
serverlog.Init(true, true, 7, "/home/joe/logs/myServerLogs")
```

4 logging functions are available.
```
serverlog.Startup("server listening on port:", PORT) // for startup logging

{'fraction_non_alphanumeric': 0.06938619900876858, 'fraction_numerical': 0.010293556995806329, 'mean_word_length': 4.175542406311637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7497980', 'n_tokens_mistral': 711, 'n_tokens_neox': 677, 'n_words': 402}