mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	daemon/logger/jsonfilelog: avoid some allocations
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
		
							parent
							
								
									9707286a5c
								
							
						
					
					
						commit
						132da3f036
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -7,6 +7,7 @@ import (
 | 
			
		|||
 | 
			
		||||
	"github.com/docker/docker/daemon/logger"
 | 
			
		||||
	"github.com/docker/docker/pkg/jsonlog"
 | 
			
		||||
	"github.com/docker/docker/pkg/timeutils"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// JSONFileLogger is Logger implementation for default docker logging:
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +34,11 @@ func New(filename string) (logger.Logger, error) {
 | 
			
		|||
func (l *JSONFileLogger) Log(msg *logger.Message) error {
 | 
			
		||||
	l.mu.Lock()
 | 
			
		||||
	defer l.mu.Unlock()
 | 
			
		||||
	err := (&jsonlog.JSONLog{Log: string(msg.Line) + "\n", Stream: msg.Source, Created: msg.Timestamp}).MarshalJSONBuf(l.buf)
 | 
			
		||||
	timestamp, err := timeutils.FastMarshalJSON(msg.Timestamp)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	err = (&jsonlog.JSONLogBytes{Log: append(msg.Line, '\n'), Stream: msg.Source, Created: timestamp}).MarshalJSONBuf(l.buf)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue