Fix translations for "The Beego loggin system" in 13.4.md

This commit is contained in:
Anchor
2015-01-28 22:48:37 -08:00
committed by James Miranda
parent cc5242bd14
commit 3d7ae1b5ca

View File

@@ -6,12 +6,11 @@ Previously in the book, we saw that event logging plays a very important role in
Setting up server configuration module for deploying an application involves a number of different server settings. For example, we typically need to provide information regarding database configuration, listening ports, etc., via the configuration file. Setting up a centralized configuration file allows us the flexibility of deploying on different machines and connecting to remote databases, if needed.
## Beego log design
## The Beego logging system
beego deployment log design ideas from seelog, depending on the level for logging, but beego relatively lightweight logging system design, the use of the system log.Logger interfaces, the default output to os.Stdout, users can implement this interface then through beego.SetLogger set custom output, detailed implementation is as follows:
The Beego logger's design borrows ideas from seelog provides similar functionality in terms of setting logging levels. Beego's system is, however, more lightweight and makes use of the Go's `log.Logger` interface. By default, logs are outputted to os.Stdout, but users can implement this interface through `beego.SetLogger` to customize this. A detailed example of an implemented interface can be seen below:
// Log levels to control the logging output.
// Log levels for controlling the logging output.
const (
LevelTrace = iota
LevelDebug
@@ -25,7 +24,7 @@ beego deployment log design ideas from seelog, depending on the level for loggin
var level = LevelTrace
// LogLevel returns the global log level and can be used in
// own implementations of the logger interface.
// a custom implementations of the logger interface.
func Level() int {
return level
}
@@ -36,7 +35,7 @@ beego deployment log design ideas from seelog, depending on the level for loggin
level = l
}
This section implements the above log log grading system, the default level is the Trace, users can set different grading SetLevel.
This section implements the above log grading system. The default level is set to Trace and users can customize grading levels using `SetLevel`.
// logger references the used application logger.
var BeeLogger = log.New(os.Stdout, "", log.Ldate|log.Ltime)
@@ -88,32 +87,32 @@ This section implements the above log log grading system, the default level is t
}
}
Above this piece of code initializes a BeeLogger default object, the default output to os.Stdout, users can achieve a logger beego.SetLogger to set the interface output. Which are to achieve the six functions:
The code snippet above initializes a `BeeLogger` object by default, outputting logs to `os.Stdout`. As mentioned, users can implement `beego.SetLogger` to customize the logger's output. `BeeLogger` implements six functions:
- Trace( general record information, for example as follows:)
- Trace (record general information, for example:)
- "Entered parse function validation block"
- "Validation: entered second 'if'"
- "Dictionary 'Dict' is empty. Using default value"
- Debug( debug information, for example as follows:)
- Debug (debugging information, for example:)
- "Web page requested: http://somesite.com Params = '...'"
- "Response generated. Response size: 10000. Sending."
- "New file received. Type: PNG Size: 20000"
- Info( print information, for example as follows:)
- Info (printing general information, for example:)
- "Web server restarted"
- "Hourly statistics: Requested pages: 12345 Errors: 123..."
- "Service paused. Waiting for 'resume' call"
- Warn( warning messages, for example as follows:)
- Warn (warning messages, for example:)
- "Cache corrupted for file = 'test.file'. Reading from back-end"
- "Database 192.168.0.7/DB not responding. Using backup 192.168.0.8/DB"
- "No response from statistics server. Statistics not sent"
- Error( error messages, for example as follows:)
- Error (error messages, for example:)
- "Internal error. Cannot process request# 12345 Error:...."
- "Cannot perform login: credentials DB not responding"
- Critical( fatal error, for example as follows:)
- Critical (fatal errors, for example:)
- "Critical panic received:.... Shutting down"
- "Fatal error:... App is shutting down to prevent data corruption or loss"
Each function can be seen on the level of judgment which has, so if we set at deployment time level = LevelWarning, then Trace, Debug, Info will not have any of these three functions output, and so on.
You can see that each of these levels has a specific purpose. For instance if we set the logging level to Warn (`level=LevelWarning`), at the time of deployment, all of the lower level logs (Trace, Debug, Info) will not output anything.
## Beego configuration design