Skip to content
πŸ“ A self-hosted log aggregation tool.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
static
.babelrc
.gitignore
Makefile
README.md Update README.md Feb 21, 2019
app-menu.js Added save dialog to save menu item. Aug 20, 2018
app.js Moved send request under once event handler. Aug 20, 2018
icon.png
package.json Updated packages. Feb 21, 2019
port.js
screenshot.jpg
web.js Removed code to automatically save log file to desktop. Aug 20, 2018

README.md

LumberLogs

A self-hosted log aggregation tool.

Setup

Install required packages via node.

$ npm install

Run the server.

$ npm start

Running the server with a custom port.

$ PORT=5000 npm start

Usage

Bash

$ curl -H "content-type:text/plain" -d 'Hello, world.' http://localhost:1234/log
$ curl -H "content-type:application/json" -d '{"message":"Hello, world."}' http://localhost:1234/log

JavaScript

fetch('http://localhost:1234/log', {
    method: 'POST',
    body: 'Hello, world.'
});
fetch('http://localhost:1234/log', {
    method: 'POST',
    body: JSON.stringify({ message: 'Hello, world.' }),
    headers: {
        'Content-Type': 'application/json'
    }
});

Unity

using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

namespace CandyCoded.CommonComponents
{

    public class Logger : MonoBehaviour
    {

#pragma warning disable CS0649
        [SerializeField]
        private string url;
#pragma warning restore CS0649

        private int failedConnections;

        private const int maxFailedConnections = 10;

#if UNITY_EDITOR || DEVELOPMENT_BUILD

        private void OnEnable()
        {

            Application.logMessageReceived += HandleLog;

        }

        private void OnDisable()
        {

            Application.logMessageReceived -= HandleLog;

        }

#endif

        private void HandleLog(string logString, string stackTrace, LogType type)
        {

            if (url != null && failedConnections < maxFailedConnections)
            {

                var loggingForm = new WWWForm();

                loggingForm.AddField("Type", type.ToString());
                loggingForm.AddField("Message", logString);
                loggingForm.AddField("Stack_Trace", stackTrace);
                loggingForm.AddField("Device_Model", SystemInfo.deviceModel);

                StartCoroutine(SendDataToLumberLog(loggingForm));

            }

        }

        private IEnumerator SendDataToLumberLog(WWWForm form)
        {
            using (UnityWebRequest www = UnityWebRequest.Post(url, form))
            {

                yield return www.SendWebRequest();

                if (www.isNetworkError || www.isHttpError)
                {

                    Debug.LogError(www.error);

                    failedConnections += 1;

                }

            }

        }

    }

}
You can’t perform that action at this time.