Skip to content

Commit

Permalink
Merge pull request #272 from Z-Bolt/2.7.0-dev
Browse files Browse the repository at this point in the history
merge 2.7.0-dev into master
  • Loading branch information
JeffB42 authored Mar 27, 2021
2 parents 7ef3c02 + b6fdb9d commit 1f40974
Show file tree
Hide file tree
Showing 216 changed files with 7,863 additions and 1,814 deletions.
2 changes: 1 addition & 1 deletion Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ JESSIE_GO_TAGS := gtk_3_14

# Build information
#GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7)
VERSION := 2.6.1
VERSION := 2.7.0
BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S)
#BRANCH = $(shell git rev-parse --abbrev-ref HEAD)

Expand Down
2 changes: 1 addition & 1 deletion debian/octoscreen.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ExecStart=/usr/bin/xinit /usr/bin/OctoScreen -- :0 -nolisten tcp -nocursor
ExecStartPost=/bin/bash /etc/octoscreen/disablescreenblank.sh 0
StandardOutput=journal
Restart=always
WatchdogSec=10s
WatchdogSec=20s

[Install]
WantedBy=graphical.target
Expand Down
45 changes: 45 additions & 0 deletions docs/ButtonImages.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
body {
font-family: Arial, Helvetica, sans-serif;
color: white;
background-color: rgb(143, 194, 60);
background-color: black;
margin: 20px;
}
Expand Down Expand Up @@ -65,6 +66,23 @@
<img src="../styles/z-bolt/images/extruder.svg" />
<div>extruder</div>


<img src="../styles/z-bolt/images/extruder-typeB.svg" />
<div>extruder-typeB</div>

<img src="../styles/z-bolt/images/extruder-typeB-1.svg" />
<div>extruder-typeB-1</div>

<img src="../styles/z-bolt/images/extruder-typeB-2.svg" />
<div>extruder-typeB-2</div>

<img src="../styles/z-bolt/images/extruder-typeB-3.svg" />
<div>extruder-typeB-3</div>

<img src="../styles/z-bolt/images/extruder-typeB-4.svg" />
<div>extruder-typeB-4</div>


<img src="../styles/z-bolt/images/fan-off.svg" />
<div>fan-off</div>

Expand All @@ -83,6 +101,9 @@
<img src="../styles/z-bolt/images/filament-spool.svg" />
<div>filament-spool</div>

<img src="../styles/z-bolt/images/file-gcode.svg" />
<div>file-gcode</div>

<img src="../styles/z-bolt/images/file-stl.svg" />
<div>file-stl</div>

Expand Down Expand Up @@ -182,6 +203,9 @@
<img src="../styles/z-bolt/images/nozzle.svg" />
<div>nozzle</div>

<img src="../styles/z-bolt/images/octoprint-tentacle.svg" />
<div>octoprint-tentacle</div>

<img src="../styles/z-bolt/images/open.svg" />
<div>open</div>

Expand Down Expand Up @@ -221,6 +245,27 @@
<img src="../styles/z-bolt/images/shutdown.svg" />
<div>shutdown</div>

<img src="../styles/z-bolt/images/speed-0%.svg" />
<div>speed-0%</div>

<img src="../styles/z-bolt/images/speed-17%.svg" />
<div>speed-17%</div>

<img src="../styles/z-bolt/images/speed-34%.svg" />
<div>speed-34%</div>

<img src="../styles/z-bolt/images/speed-50%.svg" />
<div>speed-50%</div>

<img src="../styles/z-bolt/images/speed-67%.svg" />
<div>speed-67%</div>

<img src="../styles/z-bolt/images/speed-83%.svg" />
<div>speed-83%</div>

<img src="../styles/z-bolt/images/speed-100%.svg" />
<div>speed-100%</div>

<img src="../styles/z-bolt/images/speed-fast.svg" />
<div>speed-fast</div>

Expand Down
5 changes: 3 additions & 2 deletions interfaces/ITemperatureDataDisplay.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package interfaces

import (
"github.com/mcuadros/go-octoprint"
// "github.com/Z-Bolt/OctoScreen/octoprintApis"
"github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
)

type ITemperatureDataDisplay interface {
UpdateTemperatureData(temperatureData map[string]octoprint.TemperatureData)
UpdateTemperatureData(temperatureData map[string]dataModels.TemperatureData)
}
38 changes: 38 additions & 0 deletions logger/contextHook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package logger

import (
// "io"
// "os"
"path"
"runtime"
"strings"
// "time"

"github.com/sirupsen/logrus"
)


type ContextHook struct{}

func (hook ContextHook) Levels() []logrus.Level {
return logrus.AllLevels
}

func (hook ContextHook) Fire(entry *logrus.Entry) error {
pc := make([]uintptr, 3, 3)
cnt := runtime.Callers(6, pc)

for i := 0; i < cnt; i++ {
fu := runtime.FuncForPC(pc[i] - 1)
name := fu.Name()
if !strings.Contains(strings.ToLower(name), "github.com/sirupsen/logrus") {
file, line := fu.FileLine(pc[i] - 1)
entry.Data["file"] = path.Base(file)
entry.Data["func"] = path.Base(name)
entry.Data["line"] = line
break
}
}

return nil
}
186 changes: 186 additions & 0 deletions logger/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package logger

import (
"fmt"
"io"
standardLog "log"
"os"
// "path"
// "runtime"
"strings"
"sync"
// "time"

"github.com/sirupsen/logrus"
)


var _mutex *sync.RWMutex = nil
var _indentLevel int = -1
var _indentation string = ""
const INDENTATION_TOKEN = " "
const INDENTATION_TOKEN_LENGTH = 4

var _logrusLogger *logrus.Logger
var _logrusEntry *logrus.Entry
var _logLevel logrus.Level
var _strLogLevel string


func init() {
_mutex = &sync.RWMutex {}

_indentLevel = 0
_indentation = ""

_logrusLogger = logrus.New()
_logrusLogger.AddHook(ContextHook{})

//
// TODO: ...(maybe?) it would be nice it this could be made generic,
// but this is getting set in init().
var logFilePath = os.Getenv("OCTOSCREEN_LOG_FILE_PATH")
//

if logFilePath == "" {
standardLog.Print("logger.init() - logFilePath is was not defined. Now using just the standard console output.")
_logrusLogger.Out = os.Stdout
} else {
standardLog.Printf("logger.init() - logFilePath is: %s", logFilePath)
file, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil {
standardLog.Printf("logger.init() - OpenFile() succeeded and now setting log.Out to %s", logFilePath)
_logrusLogger.Out = file

_logrusLogger.Out = io.MultiWriter(os.Stdout, file)
logrus.SetOutput(_logrusLogger.Out)
} else {
standardLog.Printf("logger.init() - OpenFile() FAILED! err is: %s", err.Error())
standardLog.Print("Failed to open the log file, defaulting to use the standard console output.")
_logrusLogger.Out = os.Stdout
}
}

_logrusEntry = _logrusLogger.WithFields(logrus.Fields{})

// Start off with the logging level set to debug until we get a chance to read the configuration settings.
SetLogLevel(logrus.DebugLevel)
}

func readIndentation() string {
_mutex.RLock()
var indentation = _indentation
_mutex.RUnlock()

return indentation
}

func writeIndentation(indentation string) {
_mutex.Lock()
_indentation = indentation
_mutex.Unlock()
}


func SetLogLevel(newLevel logrus.Level) {
_logLevel = newLevel
_strLogLevel = strings.ToLower(_logLevel.String())

_logrusLogger.SetLevel(_logLevel)
standardLog.Printf("logger.SetLogLevel() - the log level is now set to: %s", _strLogLevel)
}

func LogLevel() string {
// Returns a lower case string.
return _strLogLevel
}


func TraceEnter(functionName string) {
message := fmt.Sprintf("%sentering %s", readIndentation(), functionName)
_logrusEntry.Debug(message)
_indentLevel++
indentation := readIndentation() + INDENTATION_TOKEN
writeIndentation(indentation)
}

func TraceLeave(functionName string) {
_indentLevel--

indentation := readIndentation()
indentation = indentation[:(_indentLevel * INDENTATION_TOKEN_LENGTH)]
writeIndentation(indentation)

message := fmt.Sprintf("%sleaving %s", readIndentation(), functionName)
_logrusEntry.Debug(message)
}


func LogError(currentFunctionName, functionCalledName string, err error) {
if err != nil {
_logrusEntry.Errorf("%s%s - %s returned an error: %q", readIndentation(), currentFunctionName, functionCalledName, err)
} else {
_logrusEntry.Errorf("%s%s - %s returned an error", readIndentation(), currentFunctionName, functionCalledName)
}
}

func LogFatalError(currentFunctionName, functionCalledName string, err error) {
if err != nil {
_logrusEntry.Fatalf("%s%s - %s returned an error: %q", readIndentation(), currentFunctionName, functionCalledName, err)
} else {
_logrusEntry.Fatalf("%s%s - %s returned an error", readIndentation(), currentFunctionName, functionCalledName)
}
}


func Debug(args ...interface{}) {
_logrusEntry.Debug(readIndentation() + fmt.Sprint(args...))
}

func Debugf(format string, args ...interface{}) {
_logrusEntry.Debugf(readIndentation() + format, args...)
}


func Info(args ...interface{}) {
_logrusEntry.Info(readIndentation() + fmt.Sprint(args...))
}

func Infof(format string, args ...interface{}) {
_logrusEntry.Infof(readIndentation() + format, args...)
}


func Warn(args ...interface{}) {
_logrusEntry.Warn(readIndentation() + fmt.Sprint(args...))
}

func Warnf(format string, args ...interface{}) {
_logrusEntry.Warnf(readIndentation() + format, args...)
}


func Error(args ...interface{}) {
_logrusEntry.Error(readIndentation() + fmt.Sprint(args...))
}

func Errorf(format string, args ...interface{}) {
_logrusEntry.Errorf(readIndentation() + format, args...)
}


func Fatal(args ...interface{}) {
_logrusEntry.Fatal(readIndentation() + fmt.Sprint(args...))
}

func Fatalf(format string, args ...interface{}) {
_logrusEntry.Fatalf(readIndentation() + format, args...)
}

func Panic(args ...interface{}) {
_logrusEntry.Panic(readIndentation() + fmt.Sprint(args...))
}

func Panicf(format string, args ...interface{}) {
_logrusEntry.Panicf(readIndentation() + format, args...)
}
Loading

0 comments on commit 1f40974

Please sign in to comment.